create-e.x.p.r.re.s.s-app
v1.2.27
Published
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![npm version](https://badge.fury.io/js/cea.svg)](https://badge.fury.io/js/cea)
Downloads
53
Maintainers
Keywords
Readme
CEA (Create Express App)
Overview
The CEA (Create Express App) npm package simplifies the setup of a full-stack web application with user authentication. It provides a template Express.js backend and a React frontend, complete with essential middleware for security, authentication, and database interactions. The package aims to streamline the development process, allowing developers to focus on building features rather than dealing with boilerplate code and configuration.
Features
- Express.js backend with security middleware (CORS, CSRF protection, helmet)
- User authentication with JSON Web Tokens (JWT) and bcrypt for password hashing
- React frontend with Redux for state management
- Sequelize ORM for database interactions (SQLite for development, PostgreSQL for production)
- Convenient scripts for migrating and seeding databases
Installation
To reate an Express app, run this command in your project's root folder:
npx create-e.x.p.r.re.s.s-app
Navigate to the /backend directory and start the server:
cd backend && npm start
Navigate to the /frontend directory and start the React app:
cd frontend && npm start
To make changes to the migrations you must unseed and unapply migrations
Configuration
Environment Variables
Environment variables are already included in /backend:
PORT=8000
DB_FILE=db/dev.db
JWT_SECRET=«generate_strong_secret_here»
JWT_EXPIRES_IN=604800
SCHEMA=«custom_schema_name_here»
Database Migration and Seeding
Migrate Database:
Run the following command to perform migrations:
npx dotenv sequelize db:migrate
Seed Database:
Run the following command to seed the database:
npx dotenv sequelize db:seed:all
Unseed Database:
To unseed the database, run:
npx dotenv sequelize db:seed:undo:all
Unmigrate Database:
To unapply migrations, run:
npx dotenv sequelize db:migrate:undo:all
Reapply Migrations and Seeds:
To make changes to migrations, first, unseed and unapply migrations, then reapply and reseed:
npx dotenv sequelize db:seed:undo:all
npx dotenv sequelize db:migrate:undo:all
npx dotenv sequelize db:migrate
npx dotenv sequelize db:seed:all
Deploying to Render:
Create a PostgreSQL Database, name it and choose your region. Copy the Internal DB URL.
Start a new Web Service
Choose your Github repo
Name your web service and choose your region.
Build command
npm install && npm run render-postbuild && npm run build && npm run sequelize --prefix backend db:migrate && npm run sequelize --prefix backend db:seed:all
Add Environment variables
PORT=8000 DB_FILE=db/dev.db JWT_SECRET=(click 'Generate') JWT_EXPIRES_IN=604800 SCHEMA=«custom_schema_name_here» NODE_ENV=production
Create Web Service