https://github.com/konijima/ts-node-web-server
Express, Socket-IO, MongoDB & Angular2 boilerplate written in Typescript.
https://github.com/konijima/ts-node-web-server
angular2 authentication boilerplate mongodb nodejs server typescript
Last synced: 3 months ago
JSON representation
Express, Socket-IO, MongoDB & Angular2 boilerplate written in Typescript.
- Host: GitHub
- URL: https://github.com/konijima/ts-node-web-server
- Owner: Konijima
- License: apache-2.0
- Created: 2022-05-08T18:59:20.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-22T19:06:40.000Z (about 4 years ago)
- Last Synced: 2025-04-09T15:50:07.428Z (about 1 year ago)
- Topics: angular2, authentication, boilerplate, mongodb, nodejs, server, typescript
- Language: TypeScript
- Homepage:
- Size: 293 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Typescript Node Web Server
`Express`, `Socket-IO`, `MongoDB` & `Angular2` boilerplate written in `Typescript`.
- Launch your own web server and serve an Angular2 front-page.
- Server/Client Authentication Ready.
- Instruction for production installation on linux (ubuntu).
## Install
```bash
# Clone the repo
git clone https://github.com/Konijima/ts-node-web-server.git
# Install Server
cd ts-node-web-server && npm install
# Install Angular
cd web && npm install
```
## Server
```bash
# Run the server in watch mode (require nodemon installed globally)
npm run watch
# Build & Run
npm run build && npm start
```
## Angular Web App
> Angular will build into `./web/dist/` and will be served by the server.
```bash
# Go into the directory
cd web
# Run the app into dev mode
ng build --watch --configuration development
# Build for production
ng build
```
## Configure
> Update the `.env` file
> Remove the `!.env` entry from the `.gitignore` before pushing your own config.
```bash
# Server local ip address
HOST = 127.0.0.1
# Server local port
PORT = 3000
# Domain name without the protocol
DOMAIN = mydomainname.com
# Full mongo database connection string
DATABASE = mongodb://localhost:27017/ts-node-web-server
# Total Seconds before a session expire
SESSION_EXPIRATION = 3600
# Secret key to sign session tokens
JWT_KEY = change_me
```
## Nginx Proxy
```bash
# Install nginx on linux (ubuntu)
sudo apt install nginx
# Enable nginx service
sudo systemctl enable nginx
# Copy the example config to nginx
sudo cp .nginx-config /etc/nginx/sites-enabled/ts-node-web-server.conf
# Edit the config using your editor of choice
nano /etc/nginx/sites-enabled/ts-node-web-server.conf
# Test the config for errors
sudo nginx -t
# Restart nginx
sudo systemctl restart nginx
```
## Run as service with PM2
```bash
# Install pm2 globally
sudo npm install -g pm2
# Start the server process
pm2 start "node -r module-alias/register ./dist/index.js"
# Set pm2 to start after reboot
pm2 startup
# Save pm2
pm2 save
```