This is a simple starter template to build your backend quickly and efficiently. Clone it and start building your project quicker.
This is a backend starter using Express, Prisma and Typescript. Simply clone this project, and add further functionality and modules.
- Typescript
- Express JS
- Mongodb for Express-Sessions
- SQLite (Can be switched quickly)
- Prisma ORM
- Passport JS (Local-Auth setup)
- Webpack
git clone "https://github.com/techboy-coder/express-backend-starter" && cd express-backend-starter && yarn
Don’t forget to install modules first
dev
- Running a dev server (ts-node-dev)build
- Export TypeScript to JavaScript + bundle JS into 1 file.start
- Run build +node "./production/bundle.js"
(Starts Server)dev:migrate
- Make migrations fromschema.prisma
file.
API uses Express-Sessions. This means it will generate a session cookie.
POST http://localhost:4000/v1/user/register
Json Body:
{
"name": "Bob Smith",
"email": "bob@email.com",
"password": "secret",
"password_confirmation": "secret"
}
POST http://localhost:4000/v1/user/login
Json Body:
{
"email": "bob@email.com",
"password": "secret"
}
GET http://localhost:4000/v1/user/
User gets recognized thanks to session.
DELETE http://localhost:4000/v1/user/
GET http://localhost:4000/v1/user/protected
📦express-backend-starter
┣ 📂.git
┣ 📂prisma
┃ ┣ 📜dev.db
┃ ┗ 📜schema.prisma
┣ 📂src
┃ ┣ 📂auth
┃ ┃ ┣ 📂config
┃ ┃ ┃ ┣ 📂strategy
┃ ┃ ┃ ┃ ┗ 📜local.ts
┃ ┃ ┃ ┗ 📜passport.ts
┃ ┃ ┣ 📂middleware
┃ ┃ ┃ ┗ 📜auth.ts
┃ ┃ ┣ 📜controller.ts
┃ ┃ ┣ 📜services.ts
┃ ┃ ┗ 📜validators.ts
┃ ┣ 📂modules
┃ ┃ ┣ 📂module 1 (Implement your own ones here)
┃ ┃ ┗ 📂module 2
┃ ┣ 📜index.ts
┃ ┣ 📜README.md
┃ ┣ 📜routes.ts
┃ ┣ 📜secrets.ts
┃ ┗ 📜session.ts
┣ 📜.env.example (Change to .env)
┣ 📜.gitignore
┣ 📜package.json
┣ 📜README.md
┣ 📜tsconfig.json
┣ 📜webpack.config.js
┗ 📜yarn.lock
Made with ❤️ by techboy-coder - Express Backend Starter