A RESTful API service built with Express.js and TypeScript to power the SecondBrain content management system.
- Node.js
- Express.js
- TypeScript
- MongoDB
- JWT Authentication
- Node.js (v14 or higher)
- MongoDB
- npm or yarn
# Clone the repository
git clone https://github.com/yourusername/SecondBrainBackend.git
# Navigate to project directory
cd SecondBrainBackend
# Install dependencies
npm installCreate a .env file in the root directory:
PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
CORS_ORIGIN=http://localhost:3000POST /api/signin- User loginPOST /api/signup- Register new user
GET /api/content- Retrieve all contentPOST /api/content- Create new contentDELETE /api/content/:id- Delete content
POST /api/share- Generate share linkGET /api/share/:hash- Access shared content
# Run in development mode
npm run dev
# Build project
npm run build
# Start production server
npm startsrc/
├── config/ # Configuration files
├── middleware/ # Custom middleware
├── models/ # MongoDB models
├── routes/ # API routes
└── utils/ # Utility functions
- JWT-based authentication
- CORS protection
- Rate limiting
- Request validation
This project is configured for Vercel deployment. Required configuration:
{
"version": 2,
"builds": [
{
"src": "src/index.ts",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "src/index.ts"
}
]
}