.
├── controllers # Controllers/ Routes for each entity
├── db
│ ├── config
│ │ └── config.js # Migration config file
│ ├── config.ts # Database configurations
│ ├── migrations # Migration files
│ └── seeders # Seeder files
├── env.sample # Sample environment variables
├── express # Express configurations
├── index.ts # Root file
├── middlewares # Express Middlewares
├── models # Sequelize Models
├── services # Model services
├── types # Typing for entities and other stuff
├── utils
│ ├── AppConfig.ts # App global variables and configurations
│ ├── modelUtils.ts # Model helper functions
│ ├── modelValidation.ts # Model validation functions
│ ├── routeConfig.ts # Route decorator
│ └── tokenUtils.ts
└── views # Api view
└── index.html
You will need the following programs installed
- Postgresql (should download version 13.6)
- Nodejs (should download lts version)
- Typescript
After installed all the above programs, following these step
- Step 1: Create a database call
food_ordering_app
in postgresql(recommend using datagrip to make thing easier)
CREATE DATABASE foold_ordering_app
- Step 2: Install dependencies
cd food-ordering-app
cd server
npm install # Or yarn
- Step 3: Complete .env file
- Change file env.sample to .env
- Fill in required information
- Example
DB_NAME=food_ordering_app DB_HOST=localhost DB_USERNAME=user that own the database PORT=5002
- Step 4: Run the api
- If this is the first time you run api (this will compile ts to js and run database migrations)
npm run build # Or yarn build
- Mac OS/ Linux
npm run server # Or yarn server
- Windows
- Run
tsc -w
- Copy folder views in
server
toserver/dist
- Then run
npm run start # Or yarn start
To get the list of every route available, go to localhost:5002, you will see a screen with ui like this:
Or go to localhost:5002/api if you prefer json
format