https://github.com/app-generator/api-server-nodejs-demo
Nodejs API & React - Deploy LIVE on Render | AppSeed
https://github.com/app-generator/api-server-nodejs-demo
appseed deployment nodejs reactjs
Last synced: about 2 months ago
JSON representation
Nodejs API & React - Deploy LIVE on Render | AppSeed
- Host: GitHub
- URL: https://github.com/app-generator/api-server-nodejs-demo
- Owner: app-generator
- License: other
- Created: 2022-11-06T10:24:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-06T11:01:53.000Z (over 3 years ago)
- Last Synced: 2025-04-06T18:12:46.117Z (about 1 year ago)
- Topics: appseed, deployment, nodejs, reactjs
- Language: TypeScript
- Homepage: https://youtu.be/3yWGhJiOWRc
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [Nodejs API Server](https://appseed.us/boilerplate-code/nodejs-starter/)
Express / [Nodejs Starter](https://appseed.us/boilerplate-code/nodejs-starter/) with JWT authentication, and **SQLite** persistance - Provided by **AppSeed** [App Generator](https://appseed.us).
Authentication Flow uses `json web tokens` via Passport library - `passport-jwt` strategy.
---
👉 Learn how to [deploy this product LIVE on Render](https://youtu.be/3yWGhJiOWRc) using the [Python Deployer](https://github.com/app-generator/deploy-automation-render) (free tool)
---
> Features:
- ✅ [API Definition](https://docs.appseed.us/boilerplate-code/api-unified-definition) - the unified API structure implemented by this server
- ✅ Simple, intuitive codebase - can be extended with ease.
- ✅ `TypeScript`, `Joy` for validation
- ✅ **Stack**: NodeJS / Express / SQLite / TypeORM
- ✅ Auth: Passport / `passport-jwt` strategy
> Tested with:
| NodeJS | NPM | YARN |
| --- | --- | --- |
| `v18.0.0` | ❌ | ✅ |
| `v17.0.0` | ❌ | ✅ |
| `v16.13.0` | ❌ | ✅ |
| `v16.0.0` | ❌ | ❌ |
> Can be used with other [React Starters](https://appseed.us/apps/react) for a complete **Full-Stack** experience:
| [React Node JS Berry](https://appseed.us/product/berry-dashboard/api-server-nodejs/react/) | [React Node Soft Dashboard](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/) | [React Node Horizon](https://appseed.us/product/horizon-ui/api-server-nodejs/) |
| --- | --- | --- |
| [](https://appseed.us/product/berry-dashboard/api-server-nodejs/react/) | [](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/) | [](https://appseed.us/product/horizon-ui/api-server-nodejs/)

## ✨ Requirements
- [Node.js](https://nodejs.org/) >= v16.13
- [SQLite](https://www.sqlite.org/index.html)
## ✨ How to use the code
> **Step 1** - Clone the project
```bash
$ git clone https://github.com/app-generator/api-server-nodejs.git
$ cd api-server-nodejs
```
> **Step 2** - Install dependencies via `Yarn`
```bash
$ yarn
```
> **Step 3** - Run the SQLite migration via TypeORM
```
$ yarn typeorm migration:run
```
> **Step 4** - Start the API server (development mode)
```bash
$ yarn dev
```
> **Step 5** - Production Build (files generated in `build` directory)
```bash
$ yarn build
```
> **Step 6** - Start the API server for production (files served from `build/index.js`)
```bash
$ yarn start
```
The API server will start using the `PORT` specified in `.env` file (default 5000).
## ✨ Codebase Structure
```bash
< ROOT / src >
|
|-- config/
| |-- config.ts # Configuration
| |-- passport.ts # Define Passport Strategy
|
|-- migration/
| |-- some_migration.ts # database migrations
|
|-- models/
| |-- activeSession.ts # Sessions Model (Typeorm)
| |-- user.ts # User Model (Typeorm)
|
|-- routes/
| |-- users.ts # Define Users API Routes
|
|
|-- index.js # API Entry Point
|-- .env # Specify the ENV variables
|
|-- ************************************************************************
```
## ✨ SQLite Path
The SQLite Path is set in `.env`, as `SQLITE_PATH`
## ✨ Database migration
> Generate migration:
```bash
$ yarn typeorm migration:generate -n your_migration_name
```
> run migration:
```bash
$ yarn typeorm migration:run
```
## ✨ API
For a fast set up, use this POSTMAN file: [api_sample](https://github.com/app-generator/api-server-nodejs-pro/blob/master/media/api.postman_collection.json)
> **Register** - `api/users/register`
```
POST api/users/register
Content-Type: application/json
{
"username":"test",
"password":"pass",
"email":"test@appseed.us"
}
```
> **Login** - `api/users/login`
```
POST /api/users/login
Content-Type: application/json
{
"password":"pass",
"email":"test@appseed.us"
}
```
> **Logout** - `api/users/logout`
```
POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request)
{
"token":"JWT_TOKEN"
}
```
## ✨ Run the Tests
```yarn test```
## ✨ Credits
This software is provided by the core AppSeed team with an inspiration from other great NodeJS starters:
- Initial verison - coded by [Teo Deleanu](https://www.linkedin.com/in/teodeleanu/)
- [Hackathon Starter](https://github.com/sahat/hackathon-starter) - A truly amazing boilerplate for Node.js apps
- [Node Server Boilerplate](https://github.com/hagopj13/node-express-boilerplate) - just another cool starter
- [React NodeJS Argon](https://github.com/creativetimofficial/argon-dashboard-react-nodejs) - released by **Creative-Tim** and [ProjectData](https://projectdata.dev/)
---
**[Node JS API Server](https://appseed.us/boilerplate-code/nodejs-starter/)** - provided by AppSeed [App Generator](https://appseed.us)