Skip to content

Express project with Typescript support ready to start coding ⚡

Notifications You must be signed in to change notification settings

mcaligares/express-typescript

Repository files navigation

Express Typescript Template

This template should help get you started developing in Node with Express and TypeScript.

🚀 Get started

# copy env file
cp .env.development .env

# run postgres container with docker-compose
docker-compose -f docker-compose.dev.yml up --build

# install dependencies
npm install

# run server
npm start

# run migrations and seeders
npm run migration
npm run seed

# sign in
curl --request POST \
  --url http://localhost:5001/api/signin \
  --header 'Content-Type: application/json' \
  --data '{ "email": "admin@mail.com", "password": "123456" }'


# psql basic command

# open connection
psql -U root -d express_db -h localhost
# list all databases
\l
# connect to database
\c express_db
# list all tables
\dt
# table detail
\d "Users"

📦 Dev Environment

  • node version 16.14.2 the last LTS
  • npm version 8.5.0

👨‍💻 Recommended IDE Setup

These extensions are configured to be recommended to the user in the first use. You can see the recommended extensions running Show Recommended Extensions from VS Code's command palette,

⚡️ Features

✒️ Code Styling

  • ESLint rules is a tool for identifying and reporting on pattern found in the code, with the goal of making code more consistent and avoid bugs. Here are the rules used for this project:

🤖 Automation

🦾 NPM scripts

Command Description
npm run serve Builds and runs the application
npm start Starts the application in development mode using nodemon and ts-node to do hot reloading.
npm run build Builds the application at build, cleaning the folder first
npm run lint Runs lint command.
npm run test Runs the jest tests once.
npm run test:coverage Runs the jest coverage once.
npm run test:dev Runs the jest tests and watches for any change.
npm run migrate Runs the sequelize-cli command to run migrations.
npm run migrate:undo Runs the sequelize-cli command to undo migrations.
npm run seed Runs the sequelize-cli command to run seeders.
npm run seed:undo Runs the sequelize-cli command to undo seeders.

⚙️ Env variables

Variable Description
ENV Environment name. ej. development, test, production
APP_NAME Application name
APP_PORT Application port number
LOG_LEVEL Log level for logging services
DB_USERNAME Username for database configuration
DB_PASSWORD Password for database configuration
DB_DATABASE Database for database configuration
DB_HOST Host for database configuration
DB_PORT Port for database configuration
SECRET_KEY_TOKEN Secret key for access token generation
SECRET_KEY_PASSWORD Secret key for encrypt password
ADMIN_EMAIL Email for admin user
ADMIN_USERNAME Username for admin user
ADMIN_PASSWORD Password for admin user