TypeScript
Express
Prisma
Zod
Nodemon
Simple token based auth
Barebones structure
Install the project dependencies:
npm i
For development purposes, you can run the application using Nodemon to automatically restart the server when changes are detected. Execute the following command:
npm run dev
This will start the server at http://localhost:1337
by default. You can change the port in the src/index.ts
file or create an .env
file to manage the environt-specific variables separately.
For production, you can build the TypeScript files and then start the server. Run the following commands:
npm run build
npm start
The project structure is organized as follows:
src
: Contains TypeScript source filesindex.ts
: Configures and starts the Express applicationdata
: Contains stuff related to the databasedata-source.ts
Initializes and exports the Prisma instance - exportsappDataSource
modules
: Contains stuffroutes
Contains web routesauth.ts
Configures authentication requests
utilities
Contains different utilities in seperate filesauth-util.ts
Auth utilitiesroute-util.ts
Routing utilities
dist
: Output directory created during build for compiled TypeScript filespackage.json
: Project configuration and dependenciestsconfig.json
: TypeScript configuration
You can customize the project configuration i nthe tsconfig.json
file and adjust the server settings in the src/index.ts
file.