Conduit Backend
A RealWorld (Conduit) backend implemented in TypeScript + Express + Prisma (PostgreSQL).
Setup
npm install
cp .env.example .env # or edit .env
npx prisma generate
npx prisma migrate dev --name init
npm run dev
Environment
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string |
JWT_SECRET | Secret used to sign JWT tokens |
PORT | HTTP port (default 3000) |
Scripts
| Script | Purpose |
|---|---|
npm run dev | Start dev server (ts-node-dev) |
npm run build | Compile TypeScript to dist/ |
npm start | Run compiled server |
npm test | Run the Jest test suite |
npm run prisma:migrate | Run Prisma migrations |
API Endpoints
Auth / User
POST /api/users— registerPOST /api/users/login— log inGET /api/user— get current userPUT /api/user— update current user
Profiles
GET /api/profiles/:username— get a profilePOST /api/profiles/:username/follow— follow a userDELETE /api/profiles/:username/follow— unfollow a user
Articles
GET /api/articles— list articles (filters:tag,author,favorited,limit,offset)GET /api/articles/feed— feed from followed usersGET /api/articles/:slug— get articlePOST /api/articles— create articlePUT /api/articles/:slug— update articleDELETE /api/articles/:slug— delete articlePOST /api/articles/:slug/favorite— favorite articleDELETE /api/articles/:slug/favorite— unfavorite article
Comments
GET /api/articles/:slug/comments— get commentsPOST /api/articles/:slug/comments— add commentDELETE /api/articles/:slug/comments/:id— delete comment
Tags
GET /api/tags— list all tags
Auth
Send the JWT in the Authorization header as Token <jwt> (also accepts Bearer <jwt>).