Base ExpressJS is a basic source code, using Express FrameWork
- node ~ v18.19.0
- npm ~ v10.2.3
- Clone project
- Create
.env
file, copy content from .env.example to.env
file and config in.env
:
- Config Runtime Environment
# development or production
NODE_ENV=development
HOST=localhost
PORT=3456
- Config Project
APP_NAME=ExpressJS
APP_DEBUG=true
# server domain name
APP_URL_API=http://localhost:3456
# primary client domain name
APP_URL_CLIENT=http://localhost:3000
# other client domain name
# Eg: ["http://localhost:3001", "http://localhost:3002"]
OTHER_URLS_CLIENT=
# primary secret key
SECRET_KEY=
# expressed in seconds or a string describing a time span
# Eg: 60, 2 days, 10h, 7d
JWT_EXPIRES_IN=7d
# maximum number of requests per minute
REQUESTS_LIMIT_PER_MINUTE=100
- Config MongoDb Database
DB_HOST=localhost
DB_PORT=27017
DB_USERNAME=
DB_PASSWORD=
DB_NAME=
- Config Email
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
[email protected]
MAIL_FROM_NAME=
- Install package & setup
npm install
- Initialize data (Required for new database)
npm run seed
Note: By default we will use this account as the Super Admin. If you want to change it, please set two environment variables SUPER_ADMIN_EMAIL and SUPER_ADMIN_PASSWORD.
- Win32 (Windows)
set [email protected] set [email protected] npm run seed- Posix (Linux, macOS)
export [email protected] export [email protected] npm run seed- Or add these two variables to the
.env
file
- Runs the app
npm run start
- Builds the app for production to the
build
folder
npm run build
- Runs the app on
production
mode
node build/main.js
Note: remember set
NODE_ENV=production
in.env
file
Email: [email protected]
Password: [email protected]