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.
- 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
-
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
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»
Run the following command to perform migrations:
npx dotenv sequelize db:migrate
Run the following command to seed the database:
npx dotenv sequelize db:seed:all
To unseed the database, run:
npx dotenv sequelize db:seed:undo:all
To unapply migrations, run:
npx dotenv sequelize db:migrate:undo:all
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
-
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