The DevByte API is the backend service powering the DevByte Community Website.
It provides secure endpoints for user management, content delivery, and community interactions.
Built with Node.js and PostgreSQL, it follows modern backend best practices.
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- ORM/Query Builder: Sequelize
- Testing: Jest (+ Supertest for integration)
- API Style: REST
community-api-backend/
├── src/
│ ├── app.js # Express app setup
│ ├── server.js # Server entry point
│ ├── routes/ # API route definitions
│ │ └── index.js # Main router entry
│ ├── controllers/ # Request handlers (business logic entry)
│ ├── services/ # Core business logic layer
│ ├── models/ # Database models (MVP: placeholders)
│ ├── middleware/ # Custom middlewares
│ └── utils/ # Helper functions
├── tests/ # Unit and integration tests
├── .env # Local environment variables (not committed)
├── .env.example # Example environment variables
├── nodemon.json # Dev server config
└── package.json
git clone https://github.com/DevByte-Community/community-api-backend.git
cd community-api-backendnpm installCreate a .env file in the project root based on .env.example.
env
APP_PORT=8000
NODE_ENV=development
DATABASE_URL=postgresql://user:password@localhost:5432/devbyte
JWT_SECRET=your_secret_keynpx prisma migrate dev # Example for Prismanpm run start:devnpm run start:prodMethod Endpoint Description POST /api/v1/auth/signup Register a new user POST /api/v1/auth/login Authenticate user & token GET /api/v1/users List all users (admin) GET /api/v1/posts Fetch community posts
(More endpoints will be added as the design is finalized.)
We use ESLint and Prettier to maintain consistent code style and catch potential issues. The configuration is already set up and includes:
- ESLint with recommended rules for Node.js
- Prettier for consistent code formatting
- Pre-commit hooks to ensure code quality
# Check code for style and potential issues
npm run lint
# Automatically fix ESLint issues
npm run lint:fix
# Format code with Prettier
npm run formatThe project uses Husky and lint-staged to run checks before each commit:
- Linting and formatting on staged files
- Running all tests
This ensures that all committed code meets our quality standards. If you need to bypass these checks in an emergency (not recommended), you can use:
git commit --no-verifyWe've made specific code style choices to ensure consistency and maintainability across the project:
- Uses modern ES2021+ features
- Enforces const declarations when variables aren't reassigned
- Prohibits use of var (use let or const instead)
- Requires explicit error handling (no process.exit calls)
- Line length: Maximum 100 characters
- Quotes: Single quotes for strings
- Semicolons: Required at end of statements
- Indentation: 2 spaces
- Trailing commas: ES5 style (for cleaner git diffs)
- Line endings: LF (Unix-style)
- Unused variables must be prefixed with underscore (e.g.,
_unused) - Console usage is restricted to
console.logandconsole.error - Node.js and Jest environments are preconfigured
- Integrates with Prettier to avoid conflicts
.eslintrc.json- ESLint rules configuration.prettierrc.json- Prettier formatting options.husky/pre-commit- Pre-commit hook configurationpackage.json- Contains lint-staged configuration
Run tests locally:
npm testPlease read our CONTRIBUTING Guidelines before submitting pull requests. All contributions are welcome — from bug fixes to major feature proposals.
This project is licensed under the MIT LICENSE.