@harperdb/nestjs

0.1.1 • Public • Published

@harperdb/nestjs

A HarperDB Component for running and developing NestJS apps.

NPM Version

Most Next.js features are supported as we rely on the NestJS Server provided by NestJS to run your application.

Usage

[!NOTE] This guide assumes you're already familiar with HarperDb Components. Please review the documentation, or check out the HarperDB Next.js Example for more information.

  1. Install:
npm install @harperdb/nestjs
  1. Add to config.yaml:
'@harperdb/nestjs':
  package: '@harperdb/nestjs'
  files: '/*'
  1. Run your app with HarperDB:
harperdb run nestjs-app
  1. Within any server side code paths, you can use HarperDB Globals after importing the HarperDB package:
// app/actions.js
'use server';

import('harperdb');

export async function listDogs() {
	const dogs = [];
	for await (const dog of tables.Dog.search()) {
		dogs.push({ id: dog.id, name: dog.name });
	}
	return dogs;
}

export async function getDog(id) {
	return tables.Dog.get(id);
}
// app/dogs/[id]/page.jsx
import { getDog, listDogs } from '@/app/actions';

export async function generateStaticParams() {
	const dogs = await listDogs();

	return dogs;
}

export default async function Dog({ params }) {
	const dog = await getDog(params.id);

	return (
		<section>
			<h1>{dog.name}</h1>
			<p>Breed: {dog.get('breed')}</p>
			<p>Woof!</p>
		</section>
	);
}

/@harperdb/nestjs/

    Package Sidebar

    Install

    npm i @harperdb/nestjs

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    14.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • ethan_arrowood
    • harperdb_team
    • deliciousmonster
    • jakehdb
    • devinhdb
    • kriszyp