Registry / devops / node-typescript-koa-rest

node-typescript-koa-rest

JSON →
library1.7.0jsnpmunverified

A boilerplate project for building a REST API using Node.js, Koa framework, and TypeScript, version 1.7.0. Integrates TypeORM for SQL database operations with class-validators for entity validation. Includes JWT authentication, CORS, Winston logger, Helmet security headers, and Swagger API documentation. Designed as a starter template with a structured workflow for production-ready APIs, featuring GitHub Actions CI and Docker support. Active development with frequent updates.

npm install node-typescript-koa-rest
INSTALL
IMPORT
SIG · NODE-TYPESCRIPT-KO
N
node-typescript-koa-rest
devopsjavascriptv1.7.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Koa
import Koa from 'koa'
const Koa = require('koa')
Default import for Koa class
Router
import Router from 'koa-router'
import { Router } from 'koa-router'
Default export for koa-router
getManager
import { getManager } from 'typeorm'
const getManager = require('typeorm').getManager
Named import for TypeORM manager

Creates a Koa app with a single route that fetches all users from PostgreSQL using TypeORM.

import Koa from 'koa'; import Router from 'koa-router'; import { createConnection } from 'typeorm'; import { User } from './entity/User'; const app = new Koa(); const router = new Router(); createConnection({ type: 'postgres', host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '5432'), username: process.env.DB_USER ?? 'postgres', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', entities: [User], synchronize: true, }).then(() => { router.get('/users', async (ctx) => { const userRepository = getRepository(User); const users = await userRepository.find(); ctx.body = users; }); app.use(router.routes()); app.listen(3000); });
Debug
Known issues
gotchaRequires Node.js version 12.x or higher; engines field specifies 12.x.x, may break on older versions.
fix
Use Node >=12.0.0 or update engines in package.json
affects: <12.0.0
breakingTypeORM version not pinned; incompatible changes may arise with newer TypeORM releases.
fix
Pin TypeORM version in package.json to a known compatible version
affects: >=1.0
gotchaJWT secret and other environment variables are hardcoded in .example.env; not suitable for production without proper secret management.
fix
Use strong secrets via environment variables and rotate regularly
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'typeorm'
TypeORM not installed or missing in dependencies
fix
Run 'npm install typeorm' or check package.json
TypeError: app.use is not a function
Koa instance not created correctly (missing import or new keyword)
fix
Ensure 'const app = new Koa();' is used
Validation failed for entity User
Missing class-validator decorators or invalid input data
fix
Add validators like @IsString() to User entity properties
Upgrade
Version history
1.7.0latest on npm
Audit
Dependencies
koarequiredCore web framework for building the API
typeormrequiredObject-relational mapping for SQL databases
class-validatorrequiredValidation decorators for request entities
jsonwebtokenrequiredJWT token generation and verification for authentication
winstonrequiredLogging middleware
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
node-typescript-koa-rest — npm install node-typescript-koa-rest · libregistry