GithubHelp home page GithubHelp logo

express-starter's Introduction

Express Starter

This repository is a working express.js server for quickly scaffolding the backend of my future projects. It provides a basic folder structure and takes care of (session based) user authentication. It is opinionated and may not suit some usecases.

Features

  • TypeScript
  • PostgreSQL with Prisma ORM
  • Session authentication with express-sesssion and passport.js
  • Redis store for persisting session data

Get Started

Pre-reqs

  1. Node.js
  2. Yarn
  3. PostgreSQL
  4. Redis

Development

First, create a .env file to let node access environment variables

# Only needed for development
touch .env

Then, add environment variables to .env For DATABASE_URL, see this Prisma guide

PORT=<port-number>
SESSION_SECRET=<your-session-secret>
REDIS_URL=<redis-server-url>
DATABASE_URL=<postgresql-server-url>

Make sure both PostgreSQL and Redis are running. Finally, install dependencies and start the server

# Install dependencies
yarn install

# Compile TypeScript source code into JavsScript and watch for changes
yarn watch

# Open a new terminal, start developing
yarn dev

Deployment

This server is able to run on Heroku (free tier) via docker To deploy on Heroku, please make sure:

  1. You have Docker installed.
  2. You have a Heroku account and have Heroku Cli installed.

Then please follow this Heroku Guide. After creating the app by heroku create, you need to install Heroku PostgreSQL and Redis addons for the app to work properly:

Testing

There aren't any tests yet. However, Jest should work great with this project.

express-starter's People

Contributors

zijizhu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.