that's a typescript template for a REST Api using Prisma and Express.
this project use the following stack:
- Typescript: to guarantee typesafe code
- Express: to create a server for the api
- Prisma: a ORM to build data model, queries and operations faster
- Nodemon: to guarantee a hot reload for the local development
for the correct usage of this template, follow the steps:
- install or define the correct Node version (access NVM repository for better instructions: https://github.com/nvm-sh/nvm):
nvm install # or nvm use if you already have the version (see .nvmrc file to check)
- install the project dependencies:
yarn install # or npm install
to run the application, check the available commands:
yarn dev # run the local server
yarn build # create a build for the api
yarn start # start the server based on the build
yarn generate # generate the prisma operations/queries/types within node_modules
yarn push # sync the prisma schema with the database schema
yarn migrate:dev # create a new migration for the database
yarn migrate:reset # reset the database data
the current project structure is:
/prisma/* # all files related to prisma (schema, migrations, etc...)
/src
/app.ts # definition of the express applicaiton
/server.ts # definition of the express server
/routes/* # definitions of the individual routes using the express router
/controller/* # definition of the individual controllers using the prisma
to a better debugging and testing of the api, we recomend to use Insomnia importing the already made collection: