An extremely opinionated starter stack for building full-stack applications the Jack way.
- React
- Node.js (Express)
- PostgreSQL
- Prisma
- Postmark
- Jest
- Supertest
- ESLint
- Prettier
- Docker
- React
- Node.js
- PostgreSQL
- Prisma
- ESLint
- Vitest
- Supertest
- Codecov
- Docker
- GitHub Actions
- Postmark Email Delivery
- ip-api.com IP Geolocation
- React Email1
- Clone the repo and delete the
.gitfolder
git clone https://github.com/jackcrane/jack-stack.git your-project-name
cd your-project-name
rm -rf .git
git init- Create the
.envfile
cp .env.example .envDATABASE_URL="postgresql://..." # Your PostgreSQL connection string
POSTMARK_API_TOKEN="..." # Your Postmark API token. You can get this from the Postmark dashboard. It looks like a uuid.
JWT_SECRET="..." # A random string.- Install dependencies
cd api && yarn install
cd ..
cd app && yarn install- Start the server
cd api && yarn startcd api && yarn dev- Start the frontend
cd app && yarn start- Replace terminology with your own
Across the app replace
Snowcapwith your own project name, and change theinstructor,dispatcher, andmanagerroles to your own terminology in theverifyAuthfunction inapi/util/verifyAuth.jsand in the db schema.
- Open the app in your browser
Visit http://localhost:5173 to view the app. The server is running on 3000 but unless you are testing an API endpoint, you should not need to use it.
Warning
Stay away from the migrations folder: When doing codebase-wide find and replace, be sure to exclude the migrations folder from your search.
This project uses Vitest for testing on the backend. Tests are available via
yarn testyarn coverageTypical vitest arguments can be passed to the above commands (e.g. yarn coverage --ui).
Frontend tests are not currently available.
Test files are colocated with their respective route files inside of a test folder and named *.test.js.
This project uses Postmark for email delivery. See above for instructions on how to set up Postmark.
This project uses ip-api.com for geolocation. See above for instructions on how to set up ip-api.com.
This project uses multer for file uploads. Be sure to set up S3 credentials in .env. From there, the upload middleware in api/util/file.js can be used to upload files to S3. It can be implemented in a route like so:
import { upload } from "#file";
import { prisma } from "#prisma";
import { verifyAuth } from "#verifyAuth";
export const post = [
verifyAuth(["instructor", "dispatcher", "manager"]),
upload,
async (req, res) => {
const file = req.file;
if (!file) {
return res.status(400).json({ message: "No file uploaded" });
}
res.json({ message: "File uploaded successfully", url: file.location });
},
];Footnotes
-
NOTE: React Email is
sort ofsupported, but is not really and requires some manual work after the inital setup. The workflow is: (1) Write the email in React, (2)yarn email:export, (3) change the extension fromhtmltohbs, (4) copy the new email template into thereact-email/completefolder. To prevent having to redo work, instead of using typical React templating, include variables (in this casename) as follows:{"{{name}}"}. ↩