https://github.com/adamazad/trador-data
Trådor's Auth and API servers
https://github.com/adamazad/trador-data
authentication hapi rest
Last synced: about 2 months ago
JSON representation
Trådor's Auth and API servers
- Host: GitHub
- URL: https://github.com/adamazad/trador-data
- Owner: adamazad
- License: mit
- Created: 2020-11-12T16:28:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-25T09:46:23.000Z (over 5 years ago)
- Last Synced: 2025-01-11T06:16:06.772Z (over 1 year ago)
- Topics: authentication, hapi, rest
- Language: TypeScript
- Homepage: https://trador.netlify.app/
- Size: 452 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Trådor Back-End
Both servers share the `User` model, so a monorepo was ideal at the moment. However, an ideal configuration would be three packages:
1. `trador-models`: an NPM package containing all the models with types. Installed from source as a dependency.
2. `auth-server`: contains all Auth controllers and services.
3. `api-server`: contains all API controllers and services.
## Auth Server
See [`src/servers/auth-server`](src/servers/auth-server)
## API Server
See [`src/servers/api-server`](src/servers/api-server)
# Building
Run
```
$ npm run build
```
# Deployment
Create a copy of `.env.sample` and rename it to `.env`
```
$ cp .env.sample .env
```
All can be left as they are except for `MONGO_URI`.
Both servers can be deployed using [PM2](https://pm2.io) in a single command. The configurations are in `ecosystem.config.js`. In the command line, type:
```
$ pm2 start ecosystem.config.js
```
Each server is configured to have two instances, which is more than enough for a small-scale application.
Logs can be traced using by running:
```
$ pm2 logs
```
# Proxy
You can setup an Nginx proxy like this:
```nginx
server {
listen 80;
listen [::]:80;
server_name auth.app.io;
location / {
proxy_pass http://127.0.0.1:4001;
}
}
server {
listen 80;
listen [::]:80;
server_name api.app.io;
location / {
proxy_pass http://127.0.0.1:4002;
}
}
```