Skip to content

l13bl/nm-self-learning

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Self Learning

Demo: https://self-learning-demo.vercel.app

Development

nx serve

Deployment

Requirements:

# Install dependencies
npm ci

# [DEMO ONLY] Apply database schema
npm run prisma db push --accept-data-loss

# [DEMO ONLY] Seed database with demo data
npm run prisma db seed

# Build application
npm run build --prod

# Start server (at http://localhost:3000)
npm run start:prod

Testing

# Run all tests
npm run test

# Testing a specific application or library
nx test [APPLICATION_NAME / LIBRARY_NAME] [--watch]

When using the Jest Runner extension during development, you will see a Run and Debug CodeLens button above your tests. Use these to start individual tests. Additionally, you may want to configure "jestrunner.runOptions": ["--watch"] in your VS Code's settings.json (or using the Settings UI Extensions > Jest-Runner Config > Run Options > Add Item -> "--watch"). Afterwards, your tests will automatically start with watch mode enabled.

Recommended VS Code Extensions

In VS Code, press F1 to open the command palette and search for Extensions: Show Recommended Extensions. Afterwards, the following plugins will appear in your sidebar with an Install button.

  • Prettier: Code formatter
  • ESLint: Static analysis and coding style guidelines
  • Tailwind CSS IntelliSense: IntelliSense for Tailwind CSS classes
  • Nx Console: UI for Nx commands
  • Jest Runner: Simple way to run or debug a single (or multiple) tests from context-menu or via code lens
  • Prisma: Adds syntax highlighting, formatting, auto-completion, jump-to-definition and linting for .prisma files

Database

This project uses Prisma for database access.

To interact with the database, you can use code like the following:

import { User } from "@prisma/client"; // User is generated by Prisma from our schema
import { database } from "@self-learning/database";

function getUserById(id: string): Promise<User> {
	// all properties (user, id, ...) are type-safe!
	return database.user.findUnique({
		where: {
			id: id
		}
	});
}

Development only: After making changes to the database schema (libs/data-access//database/prisma/schema.prisma), use the following command to push these changes to the database:

npm run prisma db push

Prisma generates code according to the defined database schema. After making changes to the schema, you must trigger the code generation via the following command:

npm run prisma generate

Fill database with demo data, which is defined in seed.ts:

npm run prisma seed

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.0%
  • CSS 1.9%
  • JavaScript 1.1%
  • Other 1.0%