├── .gitignore ├── CONTRIBUTORS.md ├── src ├── middleware │ ├── index.ts │ ├── types.ts │ ├── utils.ts │ └── manager.ts ├── index.d.ts ├── router │ ├── route-utils.ts │ └── index.ts ├── context.ts └── index.ts ├── images └── avrasya.png ├── examples ├── content-types │ ├── avrasya.png │ ├── Readme.md │ ├── package.json │ ├── index.html │ ├── src │ │ └── index.ts │ ├── package-lock.json │ └── tsconfig.json ├── prisma-mongodb │ ├── src │ │ ├── index.ts │ │ ├── lib │ │ │ └── prisma.ts │ │ ├── routes │ │ │ └── users │ │ │ │ └── get.ts │ │ └── prisma │ │ │ ├── schema.prisma │ │ │ └── seed.ts │ ├── package.json │ ├── tsconfig.json │ └── package-lock.json ├── file-based-routes │ ├── src │ │ ├── index.ts │ │ └── routes │ │ │ ├── user │ │ │ ├── get.ts │ │ │ ├── [id] │ │ │ │ └── get.ts │ │ │ └── post.ts │ │ │ └── get.ts │ ├── package.json │ ├── package-lock.json │ └── tsconfig.json ├── basic-server-es6 │ ├── index.js │ ├── package.json │ └── package-lock.json └── basic-server │ ├── package.json │ ├── src │ └── index.ts │ ├── package-lock.json │ └── tsconfig.json ├── __mocks__ ├── fs.ts └── http.ts ├── .npmignore ├── sonar-project.properties ├── jest.config.js ├── .eslintrc.cjs ├── .github ├── ISSUE_TEMPLATE.md └── workflows │ └── build.yml ├── __tests__ ├── middleware-utils.test.ts ├── server.test.ts ├── middleware-manager.test.ts ├── route-utils.test.ts ├── router.test.ts └── context.test.ts ├── LICENSE ├── CONTRIBUTING.md ├── package.json ├── Readme.md └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | coverage -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | 3 | - Muhtalip Dede 4 | - Harun Sokullu -------------------------------------------------------------------------------- /src/middleware/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./manager"; 2 | export * from "./types"; -------------------------------------------------------------------------------- /images/avrasya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkThread/avrasya/HEAD/images/avrasya.png -------------------------------------------------------------------------------- /examples/content-types/avrasya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkThread/avrasya/HEAD/examples/content-types/avrasya.png -------------------------------------------------------------------------------- /examples/prisma-mongodb/src/index.ts: -------------------------------------------------------------------------------- 1 | import Avrasya from "avrasya"; 2 | const avrasya = new Avrasya(); 3 | 4 | avrasya.listen(3000); -------------------------------------------------------------------------------- /__mocks__/fs.ts: -------------------------------------------------------------------------------- 1 | const fsMock = { 2 | readFileSync: jest.fn(), 3 | createReadStream: jest.fn(), 4 | }; 5 | 6 | export = fsMock; 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | examples 2 | .github 3 | images 4 | CONTRIBUTING.md 5 | coverage 6 | __tests__ 7 | __mocks__ 8 | .eslintrc.cjs 9 | CONTRIBUTING.md -------------------------------------------------------------------------------- /examples/file-based-routes/src/index.ts: -------------------------------------------------------------------------------- 1 | import Avrasya from "avrasya"; 2 | 3 | const avrasya = new Avrasya(); 4 | 5 | avrasya.listen(3000); -------------------------------------------------------------------------------- /src/middleware/types.ts: -------------------------------------------------------------------------------- 1 | import Context from "../context"; 2 | 3 | export type Middleware = (context: Context, next: () => void) => void; 4 | -------------------------------------------------------------------------------- /examples/file-based-routes/src/routes/user/get.ts: -------------------------------------------------------------------------------- 1 | const get = (context: any) => { 2 | context.send("Hello World"); 3 | } 4 | 5 | export default get 6 | -------------------------------------------------------------------------------- /examples/file-based-routes/src/routes/user/[id]/get.ts: -------------------------------------------------------------------------------- 1 | const get = (context: any) => { 2 | context.send("Hello World"); 3 | } 4 | 5 | export default get 6 | -------------------------------------------------------------------------------- /examples/file-based-routes/src/routes/user/post.ts: -------------------------------------------------------------------------------- 1 | const post = (context: any) => { 2 | context.send("Hello World"); 3 | } 4 | 5 | export default post 6 | -------------------------------------------------------------------------------- /examples/prisma-mongodb/src/lib/prisma.ts: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from "@prisma/client"; 2 | 3 | let prisma: PrismaClient 4 | 5 | prisma = new PrismaClient() 6 | export default prisma -------------------------------------------------------------------------------- /examples/file-based-routes/src/routes/get.ts: -------------------------------------------------------------------------------- 1 | import Context from "avrasya/src/context"; 2 | const get = (context: Context) => { 3 | context.send("Hello World"); 4 | } 5 | 6 | export default get 7 | -------------------------------------------------------------------------------- /examples/prisma-mongodb/src/routes/users/get.ts: -------------------------------------------------------------------------------- 1 | import Context from "avrasya/src/context"; 2 | import prisma from "../../lib/prisma"; 3 | 4 | const get = async (context: Context) => { 5 | const users = await prisma.user.findMany(); 6 | context.send(users); 7 | } 8 | 9 | export default get; -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=ThinkThread_avrasya 2 | sonar.organization=thinkthread 3 | sonar.sources=src/ 4 | sonar.javascript.lcov.reportPaths=/coverage/lcov.info 5 | sonar.coverage.exclusions=/__mocks__/**/*,/__tests__/**/*,/coverage/**/*,/examples/**/*,/node_modules/**/*,jest.config.js -------------------------------------------------------------------------------- /examples/content-types/Readme.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | http://localhost:3000/css 3 | http://localhost:3000/js 4 | http://localhost:3000/html 5 | http://localhost:3000/json 6 | http://localhost:3000/text 7 | http://localhost:3000/file 8 | http://localhost:3000/image 9 | http://localhost:3000/redirect 10 | ``` -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | transform: { 5 | '^.+\\.ts?$': 'ts-jest', 6 | }, 7 | transformIgnorePatterns: ['/node_modules/'], 8 | modulePathIgnorePatterns: ['/dist/'], 9 | forceExit: true, 10 | detectOpenHandles: true, 11 | cache: false 12 | }; 13 | -------------------------------------------------------------------------------- /examples/basic-server-es6/index.js: -------------------------------------------------------------------------------- 1 | import avrasya from "avrasya"; 2 | 3 | const server = new avrasya.default(); 4 | 5 | server.router.get("/", (ctx) => { 6 | ctx.send("Wellcome to my real world"); 7 | }); 8 | 9 | server.use((ctx) => { 10 | console.log("middleware"); 11 | console.log(ctx.req.url + " " + ctx.req.method); 12 | }) 13 | 14 | server.listen(1923); -------------------------------------------------------------------------------- /examples/basic-server-es6/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-server-es6", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "start": "node index.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Muhtalip Dede", 12 | "license": "ISC", 13 | "dependencies": { 14 | "avrasya": "^1.0.22" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/middleware/utils.ts: -------------------------------------------------------------------------------- 1 | import Context from "../context"; 2 | import { Middleware } from "./types"; 3 | 4 | export function runMiddleware (context: Context, middlewares: Middleware[]) { 5 | let currentMiddleware = 0; 6 | 7 | function next() { 8 | if (currentMiddleware < middlewares.length) { 9 | currentMiddleware++; 10 | middlewares[currentMiddleware - 1](context, next); 11 | } 12 | } 13 | next(); 14 | } -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | import Router from './router'; 2 | import Context from './context'; 3 | 4 | declare module 'avrasya' { 5 | export class Avrasya { 6 | constructor(); 7 | port: number; 8 | env: string; 9 | router: Router; 10 | use(handler: (context: Context, next: () => void) => void): void; 11 | listen(port?: number | string): void; 12 | } 13 | export default Avrasya; 14 | } 15 | -------------------------------------------------------------------------------- /examples/basic-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "tsc && node dist/index.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Muhtalip Dede", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "typescript": "^5.2.2" 15 | }, 16 | "dependencies": { 17 | "avrasya": "^1.0.22" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/content-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "content-types", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "tsc && node dist/index.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Muhtalip Dede", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "typescript": "^5.2.2" 15 | }, 16 | "dependencies": { 17 | "avrasya": "^1.0.22" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/middleware/manager.ts: -------------------------------------------------------------------------------- 1 | import Context from "../context"; 2 | import { Middleware } from "./types"; 3 | import { runMiddleware } from "./utils"; 4 | 5 | export class MiddlewareManager { 6 | middlewares: Middleware[] = []; 7 | 8 | constructor() { 9 | this.middlewares = []; 10 | } 11 | 12 | add(middleware: Middleware) { 13 | this.middlewares.push(middleware); 14 | } 15 | 16 | run(context: Context) { 17 | runMiddleware(context, this.middlewares); 18 | } 19 | } -------------------------------------------------------------------------------- /examples/content-types/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Avrasya 7 | 8 | 9 | 10 |

Avrasya

11 |

Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility.

12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/file-based-routes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "file-based-routes", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "./dist/index.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "tsc && node ./dist/index.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Muhtalip Dede", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "typescript": "^5.2.2" 15 | }, 16 | "dependencies": { 17 | "avrasya": "^1.0.22" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /__mocks__/http.ts: -------------------------------------------------------------------------------- 1 | const mockData = JSON.stringify({ foo: "bar" }); 2 | 3 | const httpMock = { 4 | createServer: jest.fn(), 5 | IncomingMessage: jest.fn(function () { 6 | this.bodyData = mockData; 7 | return { 8 | once: jest.fn((event, callback) => { 9 | if (event === "data") { 10 | callback(this.bodyData); 11 | } 12 | }), 13 | }; 14 | }), 15 | ServerResponse: jest.fn(() => ({ 16 | writeHead: jest.fn(), 17 | write: jest.fn(), 18 | end: jest.fn(), 19 | })), 20 | }; 21 | 22 | export = httpMock; 23 | -------------------------------------------------------------------------------- /examples/basic-server/src/index.ts: -------------------------------------------------------------------------------- 1 | import Avrasya from "avrasya"; 2 | const avrasya = new Avrasya(); 3 | 4 | avrasya.router.get("/", (context) => { 5 | context.send("Hello World"); 6 | }); 7 | 8 | avrasya.use((context, next) => { 9 | console.log("middleware1"); 10 | console.log(context.req.url + " " + context.req.method); 11 | next(); 12 | }) 13 | 14 | avrasya.use((context, next) => { 15 | console.log("middleware2"); 16 | next(); 17 | }) 18 | 19 | avrasya.use((context, next) => { 20 | console.log("middleware3"); 21 | next(); 22 | }) 23 | 24 | avrasya.listen(3000); -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | 'eslint:recommended', 4 | // TODO: Upgrade to "recommended-type-checked" 5 | 'plugin:@typescript-eslint/recommended', 6 | ], 7 | plugins: ['@typescript-eslint'], 8 | parser: '@typescript-eslint/parser', 9 | parserOptions: { 10 | project: true, 11 | tsconfigRootDir: __dirname, 12 | }, 13 | ignorePatterns: ['node_modules/', 'dist/', 'examples/', '*.d.ts'], 14 | // TODO: Remove these rules 15 | rules: { 16 | "@typescript-eslint/no-explicit-any": "off", 17 | "@typescript-eslint/ban-types": "off", 18 | "@typescript-eslint/no-var-requires": "off", 19 | }, 20 | root: true, 21 | }; -------------------------------------------------------------------------------- /examples/prisma-mongodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prisma-mongodb", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "tsc && node dist/index.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Muhtalip Dede", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/node": "^20.8.9", 15 | "prisma": "5.5.2", 16 | "ts-node": "^10.9.1", 17 | "typescript": "^5.2.2" 18 | }, 19 | "dependencies": { 20 | "@prisma/client": "5.5.2", 21 | "avrasya": "^1.0.22" 22 | }, 23 | "prisma": { 24 | "seed": "ts-node src/prisma/seed.ts" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/prisma-mongodb/src/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "mongodb" 7 | url = "" // add connection string 8 | } 9 | 10 | model Post { 11 | id String @id @default(auto()) @map("_id") @db.ObjectId 12 | createdAt DateTime @default(now()) 13 | updatedAt DateTime @updatedAt 14 | title String 15 | content String? 16 | published Boolean @default(false) 17 | viewCount Int @default(0) 18 | author User @relation(fields: [authorId], references: [id]) 19 | authorId String @db.ObjectId 20 | } 21 | 22 | model User { 23 | id String @id @default(auto()) @map("_id") @db.ObjectId 24 | email String @unique 25 | name String? 26 | posts Post[] 27 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New Feature Proposal 3 | about: This template helps you propose a new feature or enhancement. 4 | title: "[Feature] " 5 | labels: new feature 6 | assignees: '' 7 | --- 8 | 9 | **Feature Proposal** 10 | 11 | Clearly and concisely describe your proposal. 12 | 13 | **Description of the Problem** 14 | 15 | What problem does this feature proposal aim to solve? Please describe the problem. 16 | 17 | **Proposed Solution** 18 | 19 | Explain the solution to solve the problem or the new feature you are proposing. 20 | 21 | **Alternatives** 22 | 23 | Are there alternative solutions or features that you've considered? Please mention them. 24 | 25 | **Additional Information** 26 | 27 | If you have any additional information or screenshots related to your proposal, you can add them here. 28 | -------------------------------------------------------------------------------- /src/router/route-utils.ts: -------------------------------------------------------------------------------- 1 | import Router from "."; 2 | 3 | export function matcher(router: Router, method: string, url: string) { 4 | const routes = router.routes[method]; 5 | 6 | if (!routes) { 7 | return null; 8 | } 9 | 10 | for (const route in routes) { 11 | if (matchRoute(route, url)) { 12 | return routes[route]; 13 | } 14 | } 15 | 16 | return null; 17 | } 18 | 19 | export function matchRoute(route: string, url: string) { 20 | const routeSegments = route.split('/'); 21 | const urlSegments = url.split('/'); 22 | 23 | if (routeSegments.length !== urlSegments.length) { 24 | return false; 25 | } 26 | 27 | for (let i = 0; i < routeSegments.length; i++) { 28 | if (routeSegments[i] !== urlSegments[i] && !routeSegments[i].startsWith(':')) { 29 | return false; 30 | } 31 | } 32 | 33 | return true; 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI Workflow 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build-and-test: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | node-version: [14.x, 16.x, 18.x] 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | cache: 'npm' 24 | - run: npm ci 25 | - run: npm run build 26 | - run: npm run test:coverage 27 | - name: SonarCloud Scan 28 | uses: sonarsource/sonarcloud-github-action@master 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 32 | # - name: Run Snyk to check for vulnerabilities 33 | # uses: snyk/actions/node@master 34 | # env: 35 | # SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} 36 | -------------------------------------------------------------------------------- /__tests__/middleware-utils.test.ts: -------------------------------------------------------------------------------- 1 | import Context from "../src/context"; 2 | import { runMiddleware } from "../src/middleware/utils"; 3 | import http from "http"; 4 | import { Socket } from "net"; 5 | 6 | jest.mock("http"); 7 | 8 | const { IncomingMessage, ServerResponse } = http; 9 | const mockIncomingMessage = new IncomingMessage(new Socket()); 10 | const mockServerResponse = new ServerResponse(mockIncomingMessage); 11 | 12 | describe("Middleware Utils", () => { 13 | it("should be defined run middleware", () => { 14 | 15 | const middlewares = []; 16 | middlewares.push((context: Context, next: () => void) => { 17 | context.send("1"); 18 | next(); 19 | }) 20 | 21 | middlewares.push((context: Context, next: () => void) => { 22 | context.send("2"); 23 | next(); 24 | }) 25 | runMiddleware(new Context(mockIncomingMessage, mockServerResponse, "/"), middlewares); 26 | 27 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/json' }); 28 | }); 29 | }) -------------------------------------------------------------------------------- /__tests__/server.test.ts: -------------------------------------------------------------------------------- 1 | import Avrasya from '../src'; 2 | 3 | describe("Server", () => { 4 | it("avrasya server should listen", () => { 5 | process.env.NODE_ENV = "development"; 6 | process.env.PORT = "3000"; 7 | 8 | const avrasya = new Avrasya(); 9 | avrasya.listen(); 10 | 11 | expect(avrasya.port).toBe("3000"); 12 | expect(avrasya.env).toBe("development"); 13 | expect(avrasya.router).toBeDefined(); 14 | 15 | avrasya.close(); 16 | }); 17 | 18 | it("avrasya server should not listen PORT", () => { 19 | process.env.PORT = "3001"; 20 | 21 | const avrasya = new Avrasya(); 22 | avrasya.listen(); 23 | 24 | expect(avrasya.port).not.toBe("3000"); 25 | 26 | avrasya.close(); 27 | }) 28 | 29 | it("avrasya server should not NODE_ENV", () => { 30 | process.env.NODE_ENV = "production"; 31 | 32 | const avrasya = new Avrasya(); 33 | avrasya.listen(); 34 | 35 | expect(avrasya.env).not.toBe("development"); 36 | 37 | avrasya.close(); 38 | }) 39 | }); 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Muhtalip Dede 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /__tests__/middleware-manager.test.ts: -------------------------------------------------------------------------------- 1 | import Context from "../src/context"; 2 | import http from "http"; 3 | import { Socket } from "net"; 4 | import { MiddlewareManager } from "../src/middleware"; 5 | 6 | jest.mock('http'); 7 | 8 | const { IncomingMessage, ServerResponse } = http; 9 | const mockIncomingMessage = new IncomingMessage(new Socket()); 10 | const mockServerResponse = new ServerResponse(mockIncomingMessage); 11 | 12 | describe("Middleware Manager", () => { 13 | it("should be defined", () => { 14 | const manager = new MiddlewareManager(); 15 | manager.add((context, next) => { 16 | context.send("1"); 17 | next(); 18 | }) 19 | expect(manager).toBeDefined(); 20 | expect(manager.middlewares).toBeDefined(); 21 | expect(manager.middlewares.length).toBe(1); 22 | }) 23 | 24 | it("should be defined run middleware", () => { 25 | const manager = new MiddlewareManager(); 26 | manager.add((context, next) => { 27 | context.send("1"); 28 | next(); 29 | }) 30 | 31 | const context = new Context(mockIncomingMessage, mockServerResponse, '/'); 32 | manager.run(context); 33 | 34 | expect(context.res.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/json' }); 35 | }) 36 | }) -------------------------------------------------------------------------------- /__tests__/route-utils.test.ts: -------------------------------------------------------------------------------- 1 | import Router from "../src/router"; 2 | import { matcher } from "../src/router/route-utils"; 3 | 4 | describe("Route Utils", () => { 5 | let router: Router; 6 | 7 | beforeEach(() => { 8 | router = new Router(); 9 | }); 10 | 11 | describe("matcher", () => { 12 | it("should be defined for existing routes", () => { 13 | router.get("/", (context) => context.send("hello")); 14 | const match = matcher(router, "GET", "/"); 15 | expect(match).toBeDefined(); 16 | }); 17 | 18 | it("should not be defined if route is not added", () => { 19 | const match = matcher(router, "GET", "/"); 20 | expect(match).toBeNull(); 21 | }); 22 | 23 | it("should not be defined for non-existent methods or urls", () => { 24 | router.get("/", (context) => context.send("hello")); 25 | 26 | let match = matcher(router, "", "/"); 27 | expect(match).toBeNull(); 28 | 29 | match = matcher(router, "GET", ""); 30 | expect(match).toBeNull(); 31 | 32 | match = matcher(router, "", ""); 33 | expect(match).toBeNull(); 34 | }); 35 | 36 | it("should be defined for routes with params", () => { 37 | router.get("/123", (context) => context.send("hello")); 38 | const match = matcher(router, "GET", "/:id"); 39 | expect(match).toBeDefined(); 40 | }); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Thank you for considering contributing to this project! Before contributing to the project, please follow these steps: 4 | 5 | 1. **Fork the Repository:** Fork this project to your own GitHub account. 6 | 7 | 2. **Clone the Repository:** Clone your forked project to your local machine. 8 | 9 | ```bash 10 | git clone https://github.com/your-github-username/avrasya.git 11 | ``` 12 | 13 | 3. **Create a Branch:** Create a new branch for adding a new feature or fixing a bug. 14 | 15 | ```bash 16 | git checkout -b new-feature 17 | ``` 18 | 19 | 4. **Make Changes:** Add your changes and improve the code. 20 | 5. **Test Your Changes:** Test your changes locally to ensure there are no errors or incompatibilities. 21 | 6. **Commit and Push:** Commit your changes and push them to your fork. 22 | 23 | ```bash 24 | git commit -m "Added a new feature" 25 | git push origin new-feature 26 | ``` 27 | 28 | 7. **Submit a Pull Request:** Go to your GitHub account, select your project branch, and create a "Pull Request." Submit the pull request to the project's main branch. 29 | 30 | 8. **Feedback:** The project team will review your pull request. Collaborate on feedback and necessary adjustments as needed. 31 | 32 | 9. **Approval and Merging:** Once your pull request is approved, it will be merged into the project's main branch. 33 | 34 | Please help make this contribution process as easy as possible by following the steps. If you have any questions or issues, you can ask for help by opening an issue or using our communication channels. 35 | 36 | Thank you, and we look forward to your contributions! 37 | 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "avrasya", 3 | "version": "1.0.25", 4 | "description": "Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility.", 5 | "main": "dist/index.js", 6 | "types": "src/index.d.ts", 7 | "scripts": { 8 | "build": "tsc", 9 | "lint": "eslint . --ext .ts,.tsx", 10 | "lint:fix": "eslint . --ext .ts,.tsx --fix", 11 | "test": "jest", 12 | "test:coverage": "jest --coverage" 13 | }, 14 | "keywords": [ 15 | "nodejs", 16 | "typescript", 17 | "web", 18 | "server" 19 | ], 20 | "author": "Muhtalip Dede", 21 | "license": "MIT", 22 | "devDependencies": { 23 | "@types/jest": "^29.5.6", 24 | "@typescript-eslint/eslint-plugin": "^6.9.1", 25 | "@typescript-eslint/parser": "^6.9.1", 26 | "eslint": "^8.52.0", 27 | "jest": "^29.7.0", 28 | "ts-jest": "^29.1.1", 29 | "typescript": "^5.2.2" 30 | }, 31 | "dependencies": { 32 | "@types/node": "^20.8.9" 33 | }, 34 | "repository": { 35 | "type": "git", 36 | "url": "git+https://github.com/ThinkThread/avrasya.git" 37 | }, 38 | "bugs": { 39 | "url": "https://github.com/ThinkThread/avrasya/issues" 40 | }, 41 | "homepage": "https://avrasya.fly.dev", 42 | "contributors": [ 43 | { 44 | "name": "Muhtalip Dede", 45 | "github": "https://github.com/muhtalipdede", 46 | "twitter": "https://twitter.com/MuhtalipDede" 47 | }, 48 | { 49 | "name": "Harun Sokullu", 50 | "github": "https://github.com/suphero", 51 | "twitter": "https://twitter.com/suphero" 52 | } 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /examples/prisma-mongodb/src/prisma/seed.ts: -------------------------------------------------------------------------------- 1 | import { PrismaClient, Prisma } from '@prisma/client' 2 | 3 | const prisma = new PrismaClient() 4 | 5 | const userData: Prisma.UserCreateInput[] = [ 6 | { 7 | name: 'Jesse', 8 | email: 'jesse@mongodb.com', 9 | posts: { 10 | create: [ 11 | { 12 | title: 'Join the MongoDB Community', 13 | content: 'https://community.mongodb.com/', 14 | published: true, 15 | }, 16 | ], 17 | }, 18 | }, 19 | { 20 | name: 'Mira', 21 | email: 'mira@mongodb.com', 22 | posts: { 23 | create: [ 24 | { 25 | title: 'Follow MongoDB on Twitter', 26 | content: 'https://www.twitter.com/mongodb', 27 | published: true, 28 | }, 29 | ], 30 | }, 31 | }, 32 | { 33 | name: 'Mike', 34 | email: 'mike@mongodb.com', 35 | posts: { 36 | create: [ 37 | { 38 | title: 'We have a podcast!', 39 | content: 'https://podcasts.mongodb.com/', 40 | published: true, 41 | }, 42 | { 43 | title: 'MongoDB on YouTube', 44 | content: 'https://www.youtube.com/c/MongoDBofficial', 45 | }, 46 | ], 47 | }, 48 | }, 49 | ] 50 | 51 | async function main() { 52 | console.log(`Start seeding ...`) 53 | for (const u of userData) { 54 | const user = await prisma.user.create({ 55 | data: u, 56 | }) 57 | console.log(`Created user with id: ${user.id}`) 58 | } 59 | console.log(`Seeding finished.`) 60 | } 61 | 62 | main() 63 | .catch((e) => { 64 | console.error(e) 65 | process.exit(1) 66 | }) 67 | .finally(() => { 68 | prisma.$disconnect() 69 | }) -------------------------------------------------------------------------------- /examples/content-types/src/index.ts: -------------------------------------------------------------------------------- 1 | import Avrasya from "avrasya"; 2 | 3 | const avrasya = new Avrasya(); 4 | 5 | avrasya.router.get("/css", (context) => { 6 | const css = ` 7 | body { 8 | background-color: red; 9 | } 10 | `; 11 | context.css(css); 12 | }); 13 | 14 | avrasya.router.get("/js", (context) => { 15 | const js = ` 16 | console.log("Hello World"); 17 | `; 18 | context.js(js); 19 | }) 20 | 21 | avrasya.router.get("/html", (context) => { 22 | const html = ` 23 |

Hello World

24 |

Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility.

25 | 26 | `; 27 | context.html(html); 28 | }); 29 | 30 | avrasya.router.get("/json", (context) => { 31 | const json = { 32 | name: "Avrasya", 33 | version: "1.0.13", 34 | description: "Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility." 35 | }; 36 | context.json(json); 37 | }) 38 | 39 | avrasya.router.get("/text", (context) => { 40 | const text = "Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility."; 41 | context.text(text); 42 | }) 43 | 44 | avrasya.router.get("/file", (context) => { 45 | const path = "index.html"; 46 | context.file(path); 47 | }) 48 | 49 | avrasya.router.get("/image", (context) => { 50 | const path = "avrasya.png"; 51 | context.file(path); 52 | }) 53 | 54 | avrasya.router.get("/redirect", (context) => { 55 | context.redirect("https://www.google.com"); 56 | }) 57 | 58 | avrasya.listen(3000); -------------------------------------------------------------------------------- /examples/basic-server-es6/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-server-es6", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "basic-server-es6", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "avrasya": "^1.0.11" 13 | } 14 | }, 15 | "node_modules/@types/node": { 16 | "version": "20.8.9", 17 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 18 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 19 | "dependencies": { 20 | "undici-types": "~5.26.4" 21 | } 22 | }, 23 | "node_modules/avrasya": { 24 | "version": "1.0.11", 25 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.11.tgz", 26 | "integrity": "sha512-lBr47FYejXeqqytfX4OhG2BuxjvjoZwsBNMaGmuSjKoJUu77mIX2d3S0txVhN4s33TeBH16POpYiylDSOkQESg==", 27 | "dependencies": { 28 | "@types/node": "^20.8.7" 29 | } 30 | }, 31 | "node_modules/undici-types": { 32 | "version": "5.26.5", 33 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 34 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 35 | } 36 | }, 37 | "dependencies": { 38 | "@types/node": { 39 | "version": "20.8.9", 40 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 41 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 42 | "requires": { 43 | "undici-types": "~5.26.4" 44 | } 45 | }, 46 | "avrasya": { 47 | "version": "1.0.11", 48 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.11.tgz", 49 | "integrity": "sha512-lBr47FYejXeqqytfX4OhG2BuxjvjoZwsBNMaGmuSjKoJUu77mIX2d3S0txVhN4s33TeBH16POpYiylDSOkQESg==", 50 | "requires": { 51 | "@types/node": "^20.8.7" 52 | } 53 | }, 54 | "undici-types": { 55 | "version": "5.26.5", 56 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 57 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /examples/basic-server/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-server", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "basic-server", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "avrasya": "^1.0.11" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^5.2.2" 16 | } 17 | }, 18 | "node_modules/@types/node": { 19 | "version": "20.8.7", 20 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", 21 | "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", 22 | "dependencies": { 23 | "undici-types": "~5.25.1" 24 | } 25 | }, 26 | "node_modules/avrasya": { 27 | "version": "1.0.11", 28 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.11.tgz", 29 | "integrity": "sha512-lBr47FYejXeqqytfX4OhG2BuxjvjoZwsBNMaGmuSjKoJUu77mIX2d3S0txVhN4s33TeBH16POpYiylDSOkQESg==", 30 | "dependencies": { 31 | "@types/node": "^20.8.7" 32 | } 33 | }, 34 | "node_modules/typescript": { 35 | "version": "5.2.2", 36 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 37 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 38 | "dev": true, 39 | "bin": { 40 | "tsc": "bin/tsc", 41 | "tsserver": "bin/tsserver" 42 | }, 43 | "engines": { 44 | "node": ">=14.17" 45 | } 46 | }, 47 | "node_modules/undici-types": { 48 | "version": "5.25.3", 49 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", 50 | "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" 51 | } 52 | }, 53 | "dependencies": { 54 | "@types/node": { 55 | "version": "20.8.7", 56 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", 57 | "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", 58 | "requires": { 59 | "undici-types": "~5.25.1" 60 | } 61 | }, 62 | "avrasya": { 63 | "version": "1.0.11", 64 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.11.tgz", 65 | "integrity": "sha512-lBr47FYejXeqqytfX4OhG2BuxjvjoZwsBNMaGmuSjKoJUu77mIX2d3S0txVhN4s33TeBH16POpYiylDSOkQESg==", 66 | "requires": { 67 | "@types/node": "^20.8.7" 68 | } 69 | }, 70 | "typescript": { 71 | "version": "5.2.2", 72 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 73 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 74 | "dev": true 75 | }, 76 | "undici-types": { 77 | "version": "5.25.3", 78 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", 79 | "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/content-types/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "content-types", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "content-types", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "avrasya": "^1.0.13" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^5.2.2" 16 | } 17 | }, 18 | "node_modules/@types/node": { 19 | "version": "20.8.9", 20 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 21 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 22 | "dependencies": { 23 | "undici-types": "~5.26.4" 24 | } 25 | }, 26 | "node_modules/avrasya": { 27 | "version": "1.0.13", 28 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.13.tgz", 29 | "integrity": "sha512-IPevxf4TI3FDI/Tew4pe/f5EzKODlLw/05pqsw7pF3myLdv+tjmctmiHUoBYfU/NJj0rpgTvLsksECCtZpZo6w==", 30 | "dependencies": { 31 | "@types/node": "^20.8.9" 32 | } 33 | }, 34 | "node_modules/typescript": { 35 | "version": "5.2.2", 36 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 37 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 38 | "dev": true, 39 | "bin": { 40 | "tsc": "bin/tsc", 41 | "tsserver": "bin/tsserver" 42 | }, 43 | "engines": { 44 | "node": ">=14.17" 45 | } 46 | }, 47 | "node_modules/undici-types": { 48 | "version": "5.26.5", 49 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 50 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 51 | } 52 | }, 53 | "dependencies": { 54 | "@types/node": { 55 | "version": "20.8.9", 56 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 57 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 58 | "requires": { 59 | "undici-types": "~5.26.4" 60 | } 61 | }, 62 | "avrasya": { 63 | "version": "1.0.13", 64 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.13.tgz", 65 | "integrity": "sha512-IPevxf4TI3FDI/Tew4pe/f5EzKODlLw/05pqsw7pF3myLdv+tjmctmiHUoBYfU/NJj0rpgTvLsksECCtZpZo6w==", 66 | "requires": { 67 | "@types/node": "^20.8.9" 68 | } 69 | }, 70 | "typescript": { 71 | "version": "5.2.2", 72 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 73 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 74 | "dev": true 75 | }, 76 | "undici-types": { 77 | "version": "5.26.5", 78 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 79 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/file-based-routes/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "file-based-routes", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "file-based-routes", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "avrasya": "^1.0.22" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^5.2.2" 16 | } 17 | }, 18 | "node_modules/@types/node": { 19 | "version": "20.8.9", 20 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 21 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 22 | "dependencies": { 23 | "undici-types": "~5.26.4" 24 | } 25 | }, 26 | "node_modules/avrasya": { 27 | "version": "1.0.22", 28 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.22.tgz", 29 | "integrity": "sha512-7C+0lGziNY9/viY+LHnT2TtkYdN2AUQOnLM78I2wQrgNKPqTb2i47Hedynhq1M9Hri0hwvKuH148dfVIMQFUYw==", 30 | "dependencies": { 31 | "@types/node": "^20.8.9" 32 | } 33 | }, 34 | "node_modules/typescript": { 35 | "version": "5.2.2", 36 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 37 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 38 | "dev": true, 39 | "bin": { 40 | "tsc": "bin/tsc", 41 | "tsserver": "bin/tsserver" 42 | }, 43 | "engines": { 44 | "node": ">=14.17" 45 | } 46 | }, 47 | "node_modules/undici-types": { 48 | "version": "5.26.5", 49 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 50 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 51 | } 52 | }, 53 | "dependencies": { 54 | "@types/node": { 55 | "version": "20.8.9", 56 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 57 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 58 | "requires": { 59 | "undici-types": "~5.26.4" 60 | } 61 | }, 62 | "avrasya": { 63 | "version": "1.0.22", 64 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.22.tgz", 65 | "integrity": "sha512-7C+0lGziNY9/viY+LHnT2TtkYdN2AUQOnLM78I2wQrgNKPqTb2i47Hedynhq1M9Hri0hwvKuH148dfVIMQFUYw==", 66 | "requires": { 67 | "@types/node": "^20.8.9" 68 | } 69 | }, 70 | "typescript": { 71 | "version": "5.2.2", 72 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 73 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 74 | "dev": true 75 | }, 76 | "undici-types": { 77 | "version": "5.26.5", 78 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 79 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/context.ts: -------------------------------------------------------------------------------- 1 | import { IncomingMessage, ServerResponse } from "http"; 2 | import url from "url"; 3 | import fs from "fs"; 4 | 5 | class Context { 6 | private path: string; 7 | req: IncomingMessage; 8 | res: ServerResponse; 9 | body: any; 10 | params: any; 11 | constructor(req: IncomingMessage, res: ServerResponse, path: string, ) { 12 | this.path = path; 13 | this.req = req; 14 | this.res = res; 15 | this.body = ''; 16 | this.params = {}; 17 | if (req.url && path.includes(':')) { 18 | this.extractParamsFromUrl(path); 19 | } 20 | } 21 | private extractParamsFromUrl(path: string) { 22 | if (!this.req.url) { 23 | return; 24 | } 25 | const urlParts = url.parse(this.req.url); 26 | const pathname = urlParts.pathname; 27 | 28 | if (!pathname) { 29 | return; 30 | } 31 | 32 | const pathSegments = pathname.split('/').filter(segment => segment !== ''); 33 | 34 | const routeSegments = path.split('/').filter(segment => segment !== ''); 35 | 36 | if (pathSegments.length === routeSegments.length) { 37 | routeSegments.forEach((segment, index) => { 38 | if (segment.startsWith(':')) { 39 | const paramName = segment.slice(1); 40 | this.params[paramName] = pathSegments[index]; 41 | } 42 | }); 43 | } 44 | } 45 | 46 | // TODO: This is same as the json method. Refactor 47 | send(data: any) { 48 | this.res.writeHead(200, { 'Content-Type': 'application/json' }); 49 | this.res.write(JSON.stringify(data)); 50 | this.res.end(); 51 | } 52 | 53 | redirect(url: string) { 54 | this.res.writeHead(302, { 'Location': url }); 55 | this.res.end(); 56 | } 57 | 58 | json(data: any) { 59 | this.res.writeHead(200, { 'Content-Type': 'application/json' }); 60 | this.res.write(JSON.stringify(data)); 61 | this.res.end(); 62 | } 63 | 64 | html(data: any) { 65 | this.res.writeHead(200, { 'Content-Type': 'text/html' }); 66 | this.res.write(data); 67 | this.res.end(); 68 | } 69 | 70 | css(data: any) { 71 | this.res.writeHead(200, { 'Content-Type': 'text/css' }); 72 | this.res.write(data); 73 | this.res.end(); 74 | } 75 | 76 | js(data: any) { 77 | this.res.writeHead(200, { 'Content-Type': 'application/javascript' }); 78 | this.res.write(data); 79 | this.res.end(); 80 | } 81 | 82 | text(data: any) { 83 | this.res.writeHead(200, { 'Content-Type': 'text/plain' }); 84 | this.res.write(data); 85 | this.res.end(); 86 | } 87 | 88 | file(path: string) { 89 | this.res.writeHead(200, { 'Content-Type': 'application/octet-stream' }); 90 | this.res.write(fs.readFileSync(path)); 91 | this.res.end(); 92 | } 93 | 94 | fileStream(path: string) { 95 | this.res.writeHead(200, { 'Content-Type': 'application/octet-stream' }); 96 | this.res.write(fs.createReadStream(path)); 97 | this.res.end(); 98 | } 99 | } 100 | export default Context; -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import http from 'http'; 2 | import fs from 'fs'; 3 | import path from 'path'; 4 | import Router from './router'; 5 | import { Middleware, MiddlewareManager } from './middleware'; 6 | import { matcher } from './router/route-utils'; 7 | import Context from './context'; 8 | 9 | export class Avrasya { 10 | port = process.env.PORT ?? 3000 11 | env = process.env.NODE_ENV ?? 'development' 12 | router: Router; 13 | private middlewareManager: MiddlewareManager; 14 | private routesDirectory: string; 15 | private server: http.Server; 16 | 17 | constructor() { 18 | this.server = http.createServer(); 19 | this.router = new Router(); 20 | this.middlewareManager = new MiddlewareManager(); 21 | this.routesDirectory = path.resolve(process.cwd()) + '/dist/routes'; 22 | } 23 | 24 | use(handler: Middleware) { 25 | this.middlewareManager.add(handler); 26 | } 27 | 28 | private checkRoutesDir() { 29 | if (fs.existsSync(this.routesDirectory)) { 30 | console.log('Loading routes ...'); 31 | this.readFilesRecursively(this.routesDirectory); 32 | } 33 | } 34 | 35 | private readFilesRecursively(directory: string) { 36 | const files = fs.readdirSync(directory); 37 | files.forEach((file) => { 38 | const filePath = path.join(directory, file); 39 | const stats = fs.statSync(filePath); 40 | if (stats.isDirectory()) { 41 | this.readFilesRecursively(filePath); 42 | } else if (file.endsWith('.js')) { 43 | const route = require(filePath); 44 | if (route.default) { 45 | const pathWithoutDirectory = '/' + filePath.replace(this.routesDirectory, '').replace('/', '').replace('.js', '').replace('[', ':').replace(']', ''); 46 | const method = filePath.replace(directory, '').replace('.js', '').replace('/', '').toUpperCase(); 47 | const path = pathWithoutDirectory.replace('/' + method.toLowerCase(), '') || '/'; 48 | console.log(path, method); 49 | if (method === 'GET') { 50 | this.router.get(path, route.default); 51 | } else if (method === 'POST') { 52 | this.router.post(path, route.default); 53 | } else if (method === 'PUT') { 54 | this.router.put(path, route.default); 55 | } else if (method === 'DELETE') { 56 | this.router.delete(path, route.default); 57 | } else { 58 | console.log(`Method ${method} is not supported.`); 59 | } 60 | } 61 | } 62 | }); 63 | } 64 | 65 | listen(port?: number | string) { 66 | if (!port) { 67 | port = this.port; 68 | } 69 | this.checkRoutesDir(); 70 | this.server = http.createServer((req, res) => { 71 | const { method, url } = req; 72 | if (method && url && this.router) { 73 | const handler = matcher(this.router, method, url); 74 | if (handler) { 75 | const context = new Context(req, res, url); 76 | this.middlewareManager.run(context); 77 | handler(req, res); 78 | } else { 79 | res.statusCode = 404; 80 | res.end(); 81 | } 82 | } else { 83 | res.statusCode = 404; 84 | res.end(); 85 | } 86 | }); 87 | this.server.listen(port, () => { 88 | console.log('Server listening on port ' + port); 89 | }); 90 | } 91 | 92 | close() { 93 | this.server.close(); 94 | } 95 | } 96 | 97 | export default Avrasya; -------------------------------------------------------------------------------- /src/router/index.ts: -------------------------------------------------------------------------------- 1 | import { IncomingMessage, ServerResponse } from "http"; 2 | import Context from "../context"; 3 | 4 | class Router { 5 | 6 | // TODO: refactor 7 | routes: { [method: string]: { [path: string]: Function } } = { 8 | GET: {}, 9 | POST: {}, 10 | PUT: {}, 11 | DELETE: {}, 12 | PATCH: {}, 13 | HEAD: {}, 14 | OPTIONS: {}, 15 | CONNECT: {}, 16 | }; 17 | 18 | constructor() { 19 | this.routes = { 20 | GET: {}, 21 | POST: {}, 22 | PUT: {}, 23 | DELETE: {}, 24 | PATCH: {}, 25 | HEAD: {}, 26 | OPTIONS: {}, 27 | CONNECT: {}, 28 | } 29 | } 30 | get(path: string, handler: (context: Context) => void) { 31 | this.routes.GET[path] = function (req: IncomingMessage, res: ServerResponse) { 32 | const context = new Context(req, res, path); 33 | handler(context); 34 | } 35 | } 36 | 37 | post(path: string, handler: (context: Context) => void) { 38 | this.routes.POST[path] = function (req: IncomingMessage, res: ServerResponse) { 39 | const context = new Context(req, res, path); 40 | let body = ''; 41 | req.once('data', chunk => { 42 | body += chunk; 43 | context.body = JSON.parse(body); 44 | handler(context); 45 | }) 46 | } 47 | } 48 | 49 | put (path: string, handler: (context: Context) => void) { 50 | this.routes.PUT[path] = function (req: IncomingMessage, res: ServerResponse) { 51 | const context = new Context(req, res, path); 52 | let body = ''; 53 | req.once('data', chunk => { 54 | body += chunk; 55 | context.body = JSON.parse(body); 56 | handler(context); 57 | }) 58 | } 59 | } 60 | 61 | delete (path: string, handler: (context: Context) => void) { 62 | this.routes.DELETE[path] = function (req: IncomingMessage, res: ServerResponse) { 63 | const context = new Context(req, res, path); 64 | handler(context); 65 | } 66 | } 67 | 68 | patch (path: string, handler: (context: Context) => void) { 69 | this.routes.PATCH[path] = function (req: IncomingMessage, res: ServerResponse) { 70 | const context = new Context(req, res, path); 71 | let body = ''; 72 | req.once('data', chunk => { 73 | body += chunk; 74 | context.body = JSON.parse(body); 75 | handler(context); 76 | }) 77 | } 78 | } 79 | 80 | head (path: string, handler: (context: Context) => void) { 81 | this.routes.HEAD[path] = function (req: IncomingMessage, res: ServerResponse) { 82 | const context = new Context(req, res, path); 83 | handler(context); 84 | } 85 | } 86 | 87 | options (path: string, handler: (context: Context) => void) { 88 | this.routes.OPTIONS[path] = function (req: IncomingMessage, res: ServerResponse) { 89 | const context = new Context(req, res, path); 90 | handler(context); 91 | } 92 | } 93 | 94 | connect (path: string, handler: (context: Context) => void) { 95 | this.routes.CONNECT[path] = function (req: IncomingMessage, res: ServerResponse) { 96 | const context = new Context(req, res, path); 97 | handler(context); 98 | } 99 | } 100 | 101 | } 102 | 103 | export default Router; -------------------------------------------------------------------------------- /__tests__/router.test.ts: -------------------------------------------------------------------------------- 1 | import Avrasya from '../src'; 2 | import http from "http"; 3 | import { Socket } from "net"; 4 | 5 | jest.mock('http'); 6 | 7 | const { IncomingMessage, ServerResponse } = http; 8 | const mockIncomingMessage = new IncomingMessage(new Socket()); 9 | const mockServerResponse = new ServerResponse(mockIncomingMessage); 10 | 11 | describe("Router", () => { 12 | it("should be defined", () => { 13 | const avrasya = new Avrasya(); 14 | expect(avrasya.router).toBeDefined(); 15 | }); 16 | 17 | it("should be defined GET method", () => { 18 | const avrasya = new Avrasya(); 19 | avrasya.router.get("/", (context) => { 20 | context.send("hello"); 21 | }); 22 | expect(avrasya.router).toBeDefined(); 23 | }); 24 | 25 | it("should be defined GET method handler is defined", () => { 26 | const avrasya = new Avrasya(); 27 | 28 | avrasya.router.get("/", (context) => { 29 | context.send("hello"); 30 | }) 31 | 32 | const handler = avrasya.router.routes['GET']['/']; 33 | 34 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 35 | 36 | expect(handler).toBeDefined(); 37 | expect(handler).toBeInstanceOf(Function); 38 | }) 39 | 40 | it("should be defined POST method", () => { 41 | const avrasya = new Avrasya(); 42 | avrasya.router.post("/", (context) => { 43 | context.send("hello"); 44 | }); 45 | expect(avrasya.router).toBeDefined(); 46 | }) 47 | 48 | it("should be defined POST method handler is defined", () => { 49 | const avrasya = new Avrasya(); 50 | 51 | avrasya.router.post("/", (context) => { 52 | context.send("hello"); 53 | }) 54 | 55 | const handler = avrasya.router.routes['POST']['/']; 56 | 57 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 58 | 59 | expect(handler).toBeDefined(); 60 | expect(handler).toBeInstanceOf(Function); 61 | }) 62 | 63 | it("should be defined PUT method", () => { 64 | const avrasya = new Avrasya(); 65 | avrasya.router.put("/", (context) => { 66 | context.send("hello"); 67 | }); 68 | expect(avrasya.router).toBeDefined(); 69 | }) 70 | 71 | it("should be defined PUT method handler is defined", () => { 72 | const avrasya = new Avrasya(); 73 | 74 | avrasya.router.put("/", (context) => { 75 | context.send("hello"); 76 | }) 77 | 78 | const handler = avrasya.router.routes['PUT']['/']; 79 | 80 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 81 | 82 | expect(handler).toBeDefined(); 83 | expect(handler).toBeInstanceOf(Function); 84 | }) 85 | 86 | it("should be defined DELETE method", () => { 87 | const avrasya = new Avrasya(); 88 | avrasya.router.delete("/", (context) => { 89 | context.send("hello"); 90 | }); 91 | expect(avrasya.router).toBeDefined(); 92 | }) 93 | 94 | it("should be defined DELETE method handler is defined", () => { 95 | const avrasya = new Avrasya(); 96 | 97 | avrasya.router.delete("/", (context) => { 98 | context.send("hello"); 99 | }) 100 | 101 | const handler = avrasya.router.routes['DELETE']['/']; 102 | 103 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 104 | 105 | expect(handler).toBeDefined(); 106 | expect(handler).toBeInstanceOf(Function); 107 | }) 108 | 109 | it("should be defined PATCH method", () => { 110 | const avrasya = new Avrasya(); 111 | avrasya.router.patch("/", (context) => { 112 | context.send("hello"); 113 | }); 114 | expect(avrasya.router).toBeDefined(); 115 | }) 116 | 117 | it("should be defined PATCH method handler is defined", () => { 118 | const avrasya = new Avrasya(); 119 | 120 | avrasya.router.patch("/", (context) => { 121 | context.send("hello"); 122 | }) 123 | 124 | const handler = avrasya.router.routes['PATCH']['/']; 125 | 126 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 127 | 128 | expect(handler).toBeDefined(); 129 | expect(handler).toBeInstanceOf(Function); 130 | }) 131 | 132 | it("should be defined HEAD method", () => { 133 | const avrasya = new Avrasya(); 134 | avrasya.router.head("/", (context) => { 135 | context.send("hello"); 136 | }); 137 | expect(avrasya.router).toBeDefined(); 138 | }) 139 | 140 | it("should be defined HEAD method handler is defined", () => { 141 | const avrasya = new Avrasya(); 142 | 143 | avrasya.router.head("/", (context) => { 144 | context.send("hello"); 145 | }) 146 | 147 | const handler = avrasya.router.routes['HEAD']['/']; 148 | 149 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 150 | 151 | expect(handler).toBeDefined(); 152 | expect(handler).toBeInstanceOf(Function); 153 | }) 154 | 155 | it("should be defined OPTIONS method", () => { 156 | const avrasya = new Avrasya(); 157 | avrasya.router.options("/", (context) => { 158 | context.send("hello"); 159 | }); 160 | expect(avrasya.router).toBeDefined(); 161 | }) 162 | 163 | it("should be defined OPTIONS method handler is defined", () => { 164 | const avrasya = new Avrasya(); 165 | 166 | avrasya.router.options("/", (context) => { 167 | context.send("hello"); 168 | }) 169 | 170 | const handler = avrasya.router.routes['OPTIONS']['/']; 171 | 172 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 173 | 174 | expect(handler).toBeDefined(); 175 | expect(handler).toBeInstanceOf(Function); 176 | }) 177 | 178 | it("should be defined CONNECT method", () => { 179 | const avrasya = new Avrasya(); 180 | avrasya.router.connect("/", (context) => { 181 | context.send("hello"); 182 | }); 183 | expect(avrasya.router).toBeDefined(); 184 | }) 185 | 186 | it("should be defined CONNECT method handler is defined", () => { 187 | const avrasya = new Avrasya(); 188 | 189 | avrasya.router.connect("/", (context) => { 190 | context.send("hello"); 191 | }) 192 | 193 | const handler = avrasya.router.routes['CONNECT']['/']; 194 | 195 | handler.call(avrasya.router, mockIncomingMessage, mockServerResponse); 196 | 197 | expect(handler).toBeDefined(); 198 | expect(handler).toBeInstanceOf(Function); 199 | }) 200 | }) -------------------------------------------------------------------------------- /__tests__/context.test.ts: -------------------------------------------------------------------------------- 1 | import http from "http"; 2 | import fs from "fs"; 3 | import Context from "../src/context"; 4 | import { Socket } from "net"; 5 | 6 | jest.mock("http"); 7 | jest.mock("fs"); 8 | 9 | const { IncomingMessage, ServerResponse } = http; 10 | const mockIncomingMessage = new IncomingMessage(new Socket()); 11 | const mockServerResponse = new ServerResponse(mockIncomingMessage); 12 | 13 | describe('Context', () => { 14 | it('should be defined', () => { 15 | mockIncomingMessage.url = '/'; 16 | const context = new Context(mockIncomingMessage, mockServerResponse, '/'); 17 | expect(context).toBeDefined(); 18 | expect(context.req).toBeDefined(); 19 | expect(context.res).toBeDefined(); 20 | }); 21 | 22 | it('should be defined with params', () => { 23 | mockIncomingMessage.url = '/1'; 24 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 25 | expect(context).toBeDefined(); 26 | expect(context.req).toBeDefined(); 27 | expect(context.res).toBeDefined(); 28 | expect(context.params).toBeDefined(); 29 | expect(context.params.id).toBeDefined(); 30 | expect(context.params.id).toBe('1'); 31 | }) 32 | 33 | it('should not be defined with params', () => { 34 | mockIncomingMessage.url = '/1'; 35 | const context = new Context(mockIncomingMessage, mockServerResponse, '/'); 36 | expect(context).toBeDefined(); 37 | expect(context.req).toBeDefined(); 38 | expect(context.res).toBeDefined(); 39 | expect(context.params).toEqual({}); 40 | }) 41 | 42 | it('should not be defined url', () => { 43 | mockIncomingMessage.url = undefined; 44 | const context = new Context(mockIncomingMessage, mockServerResponse, '/'); 45 | expect(context).toBeDefined(); 46 | expect(context.req).toBeDefined(); 47 | expect(context.res).toBeDefined(); 48 | expect(context.params).toEqual({}); 49 | }) 50 | 51 | it('should not be defined pathname', () => { 52 | mockIncomingMessage.url = ''; 53 | const context = new Context(mockIncomingMessage, mockServerResponse, '/'); 54 | expect(context).toBeDefined(); 55 | expect(context.req).toBeDefined(); 56 | expect(context.res).toBeDefined(); 57 | expect(context.params).toEqual({}); 58 | }) 59 | 60 | it('should be defined send method', () => { 61 | mockIncomingMessage.url = '/1'; 62 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 63 | context.send({ id: 1 }); 64 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/json' }); 65 | expect(mockServerResponse.write).toHaveBeenCalledWith(JSON.stringify({ id: 1 })); 66 | expect(mockServerResponse.end).toHaveBeenCalled(); 67 | }) 68 | 69 | it('should be defined redirect method', () => { 70 | mockIncomingMessage.url = '/1'; 71 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 72 | context.redirect('/2'); 73 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(302, { 'Location': '/2' }); 74 | expect(mockServerResponse.end).toHaveBeenCalled(); 75 | }) 76 | 77 | it('should be defined json method', () => { 78 | mockIncomingMessage.url = '/1'; 79 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 80 | context.json({ id: 1 }); 81 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/json' }); 82 | expect(mockServerResponse.write).toHaveBeenCalledWith(JSON.stringify({ id: 1 })); 83 | expect(mockServerResponse.end).toHaveBeenCalled(); 84 | }) 85 | 86 | it('should be defined html method', () => { 87 | mockIncomingMessage.url = '/1'; 88 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 89 | context.html('

hello

'); 90 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'text/html' }); 91 | expect(mockServerResponse.write).toHaveBeenCalledWith('

hello

'); 92 | expect(mockServerResponse.end).toHaveBeenCalled(); 93 | }) 94 | 95 | it('should be defined js method', () => { 96 | mockIncomingMessage.url = '/1'; 97 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 98 | context.js('console.log("hello");'); 99 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/javascript' }); 100 | expect(mockServerResponse.write).toHaveBeenCalledWith('console.log("hello");'); 101 | expect(mockServerResponse.end).toHaveBeenCalled(); 102 | }) 103 | 104 | it('should be defined text method', () => { 105 | mockIncomingMessage.url = '/1'; 106 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 107 | context.text('hello'); 108 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'text/plain' }); 109 | expect(mockServerResponse.write).toHaveBeenCalledWith('hello'); 110 | expect(mockServerResponse.end).toHaveBeenCalled(); 111 | }) 112 | 113 | it('should be defined css method', () => { 114 | mockIncomingMessage.url = '/1'; 115 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 116 | context.css('body { background-color: red; }'); 117 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'text/css' }); 118 | expect(mockServerResponse.write).toHaveBeenCalledWith('body { background-color: red; }'); 119 | expect(mockServerResponse.end).toHaveBeenCalled(); 120 | }) 121 | 122 | it('should be defined file method', () => { 123 | mockIncomingMessage.url = '/1'; 124 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 125 | context.file('index.html'); 126 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/octet-stream' }); 127 | expect(mockServerResponse.write).toHaveBeenCalledWith(fs.readFileSync('index.html')); 128 | expect(mockServerResponse.end).toHaveBeenCalled(); 129 | }) 130 | 131 | it('should be defined fileStream method', () => { 132 | mockIncomingMessage.url = '/1'; 133 | const context = new Context(mockIncomingMessage, mockServerResponse, '/:id'); 134 | context.fileStream('index.html'); 135 | expect(mockServerResponse.writeHead).toHaveBeenCalledWith(200, { 'Content-Type': 'application/octet-stream' }); 136 | expect(mockServerResponse.write).toHaveBeenCalledWith(fs.createReadStream('index.html')); 137 | expect(mockServerResponse.end).toHaveBeenCalled(); 138 | }) 139 | }) -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Avrasya Web Framework 2 | 3 | [![NPM Version][npm-version-image]][npm-url] 4 | [![NPM Install Size][npm-install-size-image]][npm-install-size-url] 5 | [![NPM Downloads][npm-downloads-image]][npm-downloads-url] 6 | [![Known Vulnerabilities](https://snyk.io/test/github/muhtalipdede/avrasya/badge.svg)](https://snyk.io/test/github/muhtalipdede/avrasya) 7 | [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=bugs)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 8 | [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 9 | [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 10 | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 11 | [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 12 | [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 13 | [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 14 | [![CodeFactor](https://www.codefactor.io/repository/github/muhtalipdede/avrasya/badge)](https://www.codefactor.io/repository/github/muhtalipdede/avrasya) 15 | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/ff4e1c45beb34681b3b4f9946f369c2b)](https://app.codacy.com/gh/muhtalipdede/avrasya/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) 16 | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ThinkThread_avrasya&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ThinkThread_avrasya) 17 | 18 | drawing 19 | 20 |

21 | • Official Website • 22 |

23 | Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility. 24 | 25 | ## Features 26 | 27 | - Simple and user-friendly API 28 | - Fast and efficient 29 | - Middleware support 30 | - Extensibility 31 | - Open-source and free 32 | 33 | ## Getting Started 34 | 35 | To get started with Avrasya, follow these steps: 36 | 37 | 1. Add Avrasya to your project: 38 | 39 | ```bash 40 | npm install avrasya 41 | ``` 42 | 43 | 2. Create your web server: 44 | 45 | ```typescript 46 | import Avrasya from "avrasya"; 47 | 48 | const avrasya = new Avrasya(); 49 | 50 | avrasya.router.get("/", (context) => { 51 | context.send("Hello World"); 52 | }); 53 | 54 | avrasya.use((context, next) => { 55 | console.log("middleware1"); 56 | console.log(context.req.url + " " + context.req.method); 57 | next(); 58 | }) 59 | 60 | avrasya.use((context, next) => { 61 | console.log("middleware2"); 62 | next(); 63 | }) 64 | 65 | avrasya.use((context, next) => { 66 | console.log("middleware3"); 67 | next(); 68 | }) 69 | 70 | avrasya.listen(3000); 71 | ``` 72 | 73 | ##  File Based Routing 74 | 75 | ```bash 76 | | src 77 | | index.ts 78 | | routes 79 | | get.ts 80 | | user 81 | | get.ts 82 | | [id] 83 | | get.ts 84 | | post.ts 85 | ``` 86 | 87 | ### get.ts Example Handler 88 | 89 | ```typescript 90 | import Context from "avrasya/src/context"; 91 | const get = (context: Context) => { 92 | context.send("Hello World"); 93 | } 94 | 95 | export default get 96 | ``` 97 | 98 | See [Example](./examples/file-based-routes) for more details. 99 | 100 | ## Installation 101 | 102 | To get started with Avrasya, follow these simple installation steps: 103 | 104 | 1. Clone the Repository: 105 | 106 | ```bash 107 | git clone https://github.com/muhtalipdede/avrasya.git 108 | ``` 109 | 110 | 2. Navigate to the Project Directory: 111 | 112 | ```bash 113 | cd avrasya 114 | ``` 115 | 116 | 3. Install Dependencies: 117 | 118 | ```bash 119 | npm install 120 | ``` 121 | 122 | 4. Start the Application: 123 | 124 | ```bash 125 | npm run start 126 | ``` 127 | 128 | ## Content Type Support 129 | 130 | ### Serving CSS 131 | 132 | ```javascript 133 | avrasya.router.get("/css", (context) => { 134 | const css = ` 135 | body { 136 | background-color: red; 137 | } 138 | `; 139 | context.css(css); 140 | }); 141 | ``` 142 | 143 | ### Serving Javascript 144 | 145 | ```javascript 146 | avrasya.router.get("/js", (context) => { 147 | const js = ` 148 | console.log("Hello World"); 149 | `; 150 | context.js(js); 151 | }); 152 | ``` 153 | 154 | ### Serving HTML 155 | 156 | ```javascript 157 | avrasya.router.get("/html", (context) => { 158 | const html = ` 159 |

Hello World

160 |

Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility.

161 | 162 | `; 163 | context.html(html); 164 | }); 165 | ``` 166 | 167 | ### Serving JSON 168 | 169 | ```javascript 170 | avrasya.router.get("/json", (context) => { 171 | const json = { 172 | name: "Avrasya", 173 | version: "1.0.13", 174 | description: "Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility." 175 | }; 176 | context.json(json); 177 | }); 178 | ``` 179 | 180 | ### Serving Plain Text 181 | 182 | ```javascript 183 | avrasya.router.get("/text", (context) => { 184 | const text = "Avrasya is a fast and unique Node.js web framework designed for building web applications and APIs. Avrasya stands out with its simple usage, performance, and extensibility."; 185 | context.text(text); 186 | }); 187 | ``` 188 | 189 | ### Serving Files 190 | 191 | ```javascript 192 | avrasya.router.get("/image", (context) => { 193 | const path = "avrasya.png"; 194 | context.file(path); 195 | }); 196 | ``` 197 | 198 | ### Redirecting 199 | 200 | ```javascript 201 | avrasya.router.get("/redirect", (context) => { 202 | context.redirect("https://www.google.com"); 203 | }); 204 | ``` 205 | 206 | ## Contribution Guidelines 207 | 208 | Thank you for considering contributing to this project! [CONTRIBUTING](/CONTRIBUTING.md) 209 | 210 | ## Contributors 211 | 212 | Check out the list of contributors in the [CONTRIBUTORS](/CONTRIBUTORS.md) file. 213 | 214 | ## Issue Template 215 | 216 | If you want to report an issue or request a new feature, please use the following template. [ISSUE_TEMPLATE](/.github/ISSUE_TEMPLATE.md) 217 | 218 | ## License 219 | 220 | This project is licensed under the MIT License. For more information, please refer to the [LICENSE](/LICENSE) File. 221 | 222 | [npm-downloads-image]: https://badgen.net/npm/dm/avrasya 223 | [npm-downloads-url]: https://npmcharts.com/compare/avrasya?minimal=true 224 | [npm-install-size-image]: https://badgen.net/packagephobia/install/avrasya 225 | [npm-install-size-url]: https://packagephobia.com/result?p=avrasya 226 | [npm-url]: https://npmjs.org/package/avrasya 227 | [npm-version-image]: https://badgen.net/npm/v/avrasya 228 | -------------------------------------------------------------------------------- /examples/basic-server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /examples/content-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /examples/file-based-routes/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /examples/prisma-mongodb/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | }, 109 | "include": ["src", "__tests__", "__mocks__"], 110 | "exclude": ["node_modules", "dist", "examples"], 111 | } 112 | -------------------------------------------------------------------------------- /examples/prisma-mongodb/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prisma-mongodb", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "prisma-mongodb", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@prisma/client": "5.5.2", 13 | "avrasya": "^1.0.22" 14 | }, 15 | "devDependencies": { 16 | "@types/node": "^20.8.9", 17 | "prisma": "5.5.2", 18 | "ts-node": "^10.9.1", 19 | "typescript": "^5.2.2" 20 | } 21 | }, 22 | "node_modules/@cspotcode/source-map-support": { 23 | "version": "0.8.1", 24 | "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", 25 | "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", 26 | "dev": true, 27 | "dependencies": { 28 | "@jridgewell/trace-mapping": "0.3.9" 29 | }, 30 | "engines": { 31 | "node": ">=12" 32 | } 33 | }, 34 | "node_modules/@jridgewell/resolve-uri": { 35 | "version": "3.1.1", 36 | "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", 37 | "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", 38 | "dev": true, 39 | "engines": { 40 | "node": ">=6.0.0" 41 | } 42 | }, 43 | "node_modules/@jridgewell/sourcemap-codec": { 44 | "version": "1.4.15", 45 | "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", 46 | "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", 47 | "dev": true 48 | }, 49 | "node_modules/@jridgewell/trace-mapping": { 50 | "version": "0.3.9", 51 | "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", 52 | "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", 53 | "dev": true, 54 | "dependencies": { 55 | "@jridgewell/resolve-uri": "^3.0.3", 56 | "@jridgewell/sourcemap-codec": "^1.4.10" 57 | } 58 | }, 59 | "node_modules/@prisma/client": { 60 | "version": "5.5.2", 61 | "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.5.2.tgz", 62 | "integrity": "sha512-54XkqR8M+fxbzYqe+bIXimYnkkcGqgOh0dn0yWtIk6CQT4IUCAvNFNcQZwk2KqaLU+/1PHTSWrcHtx4XjluR5w==", 63 | "hasInstallScript": true, 64 | "dependencies": { 65 | "@prisma/engines-version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a" 66 | }, 67 | "engines": { 68 | "node": ">=16.13" 69 | }, 70 | "peerDependencies": { 71 | "prisma": "*" 72 | }, 73 | "peerDependenciesMeta": { 74 | "prisma": { 75 | "optional": true 76 | } 77 | } 78 | }, 79 | "node_modules/@prisma/engines": { 80 | "version": "5.5.2", 81 | "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.5.2.tgz", 82 | "integrity": "sha512-Be5hoNF8k+lkB3uEMiCHbhbfF6aj1GnrTBnn5iYFT7GEr3TsOEp1soviEcBR0tYCgHbxjcIxJMhdbvxALJhAqg==", 83 | "devOptional": true, 84 | "hasInstallScript": true 85 | }, 86 | "node_modules/@prisma/engines-version": { 87 | "version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a", 88 | "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a.tgz", 89 | "integrity": "sha512-O+qHFnZvAyOFk1tUco2/VdiqS0ym42a3+6CYLScllmnpbyiTplgyLt2rK/B9BTjYkSHjrgMhkG47S0oqzdIckA==" 90 | }, 91 | "node_modules/@tsconfig/node10": { 92 | "version": "1.0.9", 93 | "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", 94 | "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", 95 | "dev": true 96 | }, 97 | "node_modules/@tsconfig/node12": { 98 | "version": "1.0.11", 99 | "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", 100 | "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", 101 | "dev": true 102 | }, 103 | "node_modules/@tsconfig/node14": { 104 | "version": "1.0.3", 105 | "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", 106 | "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", 107 | "dev": true 108 | }, 109 | "node_modules/@tsconfig/node16": { 110 | "version": "1.0.4", 111 | "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", 112 | "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", 113 | "dev": true 114 | }, 115 | "node_modules/@types/node": { 116 | "version": "20.8.9", 117 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 118 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 119 | "dependencies": { 120 | "undici-types": "~5.26.4" 121 | } 122 | }, 123 | "node_modules/acorn": { 124 | "version": "8.11.2", 125 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", 126 | "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", 127 | "dev": true, 128 | "bin": { 129 | "acorn": "bin/acorn" 130 | }, 131 | "engines": { 132 | "node": ">=0.4.0" 133 | } 134 | }, 135 | "node_modules/acorn-walk": { 136 | "version": "8.3.0", 137 | "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz", 138 | "integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==", 139 | "dev": true, 140 | "engines": { 141 | "node": ">=0.4.0" 142 | } 143 | }, 144 | "node_modules/arg": { 145 | "version": "4.1.3", 146 | "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", 147 | "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", 148 | "dev": true 149 | }, 150 | "node_modules/avrasya": { 151 | "version": "1.0.22", 152 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.22.tgz", 153 | "integrity": "sha512-7C+0lGziNY9/viY+LHnT2TtkYdN2AUQOnLM78I2wQrgNKPqTb2i47Hedynhq1M9Hri0hwvKuH148dfVIMQFUYw==", 154 | "dependencies": { 155 | "@types/node": "^20.8.9" 156 | } 157 | }, 158 | "node_modules/create-require": { 159 | "version": "1.1.1", 160 | "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", 161 | "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", 162 | "dev": true 163 | }, 164 | "node_modules/diff": { 165 | "version": "4.0.2", 166 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", 167 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", 168 | "dev": true, 169 | "engines": { 170 | "node": ">=0.3.1" 171 | } 172 | }, 173 | "node_modules/make-error": { 174 | "version": "1.3.6", 175 | "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", 176 | "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", 177 | "dev": true 178 | }, 179 | "node_modules/prisma": { 180 | "version": "5.5.2", 181 | "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.5.2.tgz", 182 | "integrity": "sha512-WQtG6fevOL053yoPl6dbHV+IWgKo25IRN4/pwAGqcWmg7CrtoCzvbDbN9fXUc7QS2KK0LimHIqLsaCOX/vHl8w==", 183 | "devOptional": true, 184 | "hasInstallScript": true, 185 | "dependencies": { 186 | "@prisma/engines": "5.5.2" 187 | }, 188 | "bin": { 189 | "prisma": "build/index.js" 190 | }, 191 | "engines": { 192 | "node": ">=16.13" 193 | } 194 | }, 195 | "node_modules/ts-node": { 196 | "version": "10.9.1", 197 | "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", 198 | "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", 199 | "dev": true, 200 | "dependencies": { 201 | "@cspotcode/source-map-support": "^0.8.0", 202 | "@tsconfig/node10": "^1.0.7", 203 | "@tsconfig/node12": "^1.0.7", 204 | "@tsconfig/node14": "^1.0.0", 205 | "@tsconfig/node16": "^1.0.2", 206 | "acorn": "^8.4.1", 207 | "acorn-walk": "^8.1.1", 208 | "arg": "^4.1.0", 209 | "create-require": "^1.1.0", 210 | "diff": "^4.0.1", 211 | "make-error": "^1.1.1", 212 | "v8-compile-cache-lib": "^3.0.1", 213 | "yn": "3.1.1" 214 | }, 215 | "bin": { 216 | "ts-node": "dist/bin.js", 217 | "ts-node-cwd": "dist/bin-cwd.js", 218 | "ts-node-esm": "dist/bin-esm.js", 219 | "ts-node-script": "dist/bin-script.js", 220 | "ts-node-transpile-only": "dist/bin-transpile.js", 221 | "ts-script": "dist/bin-script-deprecated.js" 222 | }, 223 | "peerDependencies": { 224 | "@swc/core": ">=1.2.50", 225 | "@swc/wasm": ">=1.2.50", 226 | "@types/node": "*", 227 | "typescript": ">=2.7" 228 | }, 229 | "peerDependenciesMeta": { 230 | "@swc/core": { 231 | "optional": true 232 | }, 233 | "@swc/wasm": { 234 | "optional": true 235 | } 236 | } 237 | }, 238 | "node_modules/typescript": { 239 | "version": "5.2.2", 240 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 241 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 242 | "dev": true, 243 | "bin": { 244 | "tsc": "bin/tsc", 245 | "tsserver": "bin/tsserver" 246 | }, 247 | "engines": { 248 | "node": ">=14.17" 249 | } 250 | }, 251 | "node_modules/undici-types": { 252 | "version": "5.26.5", 253 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 254 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 255 | }, 256 | "node_modules/v8-compile-cache-lib": { 257 | "version": "3.0.1", 258 | "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", 259 | "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", 260 | "dev": true 261 | }, 262 | "node_modules/yn": { 263 | "version": "3.1.1", 264 | "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", 265 | "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", 266 | "dev": true, 267 | "engines": { 268 | "node": ">=6" 269 | } 270 | } 271 | }, 272 | "dependencies": { 273 | "@cspotcode/source-map-support": { 274 | "version": "0.8.1", 275 | "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", 276 | "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", 277 | "dev": true, 278 | "requires": { 279 | "@jridgewell/trace-mapping": "0.3.9" 280 | } 281 | }, 282 | "@jridgewell/resolve-uri": { 283 | "version": "3.1.1", 284 | "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", 285 | "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", 286 | "dev": true 287 | }, 288 | "@jridgewell/sourcemap-codec": { 289 | "version": "1.4.15", 290 | "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", 291 | "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", 292 | "dev": true 293 | }, 294 | "@jridgewell/trace-mapping": { 295 | "version": "0.3.9", 296 | "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", 297 | "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", 298 | "dev": true, 299 | "requires": { 300 | "@jridgewell/resolve-uri": "^3.0.3", 301 | "@jridgewell/sourcemap-codec": "^1.4.10" 302 | } 303 | }, 304 | "@prisma/client": { 305 | "version": "5.5.2", 306 | "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.5.2.tgz", 307 | "integrity": "sha512-54XkqR8M+fxbzYqe+bIXimYnkkcGqgOh0dn0yWtIk6CQT4IUCAvNFNcQZwk2KqaLU+/1PHTSWrcHtx4XjluR5w==", 308 | "requires": { 309 | "@prisma/engines-version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a" 310 | } 311 | }, 312 | "@prisma/engines": { 313 | "version": "5.5.2", 314 | "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.5.2.tgz", 315 | "integrity": "sha512-Be5hoNF8k+lkB3uEMiCHbhbfF6aj1GnrTBnn5iYFT7GEr3TsOEp1soviEcBR0tYCgHbxjcIxJMhdbvxALJhAqg==", 316 | "devOptional": true 317 | }, 318 | "@prisma/engines-version": { 319 | "version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a", 320 | "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a.tgz", 321 | "integrity": "sha512-O+qHFnZvAyOFk1tUco2/VdiqS0ym42a3+6CYLScllmnpbyiTplgyLt2rK/B9BTjYkSHjrgMhkG47S0oqzdIckA==" 322 | }, 323 | "@tsconfig/node10": { 324 | "version": "1.0.9", 325 | "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", 326 | "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", 327 | "dev": true 328 | }, 329 | "@tsconfig/node12": { 330 | "version": "1.0.11", 331 | "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", 332 | "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", 333 | "dev": true 334 | }, 335 | "@tsconfig/node14": { 336 | "version": "1.0.3", 337 | "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", 338 | "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", 339 | "dev": true 340 | }, 341 | "@tsconfig/node16": { 342 | "version": "1.0.4", 343 | "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", 344 | "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", 345 | "dev": true 346 | }, 347 | "@types/node": { 348 | "version": "20.8.9", 349 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", 350 | "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", 351 | "requires": { 352 | "undici-types": "~5.26.4" 353 | } 354 | }, 355 | "acorn": { 356 | "version": "8.11.2", 357 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", 358 | "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", 359 | "dev": true 360 | }, 361 | "acorn-walk": { 362 | "version": "8.3.0", 363 | "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz", 364 | "integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==", 365 | "dev": true 366 | }, 367 | "arg": { 368 | "version": "4.1.3", 369 | "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", 370 | "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", 371 | "dev": true 372 | }, 373 | "avrasya": { 374 | "version": "1.0.22", 375 | "resolved": "https://registry.npmjs.org/avrasya/-/avrasya-1.0.22.tgz", 376 | "integrity": "sha512-7C+0lGziNY9/viY+LHnT2TtkYdN2AUQOnLM78I2wQrgNKPqTb2i47Hedynhq1M9Hri0hwvKuH148dfVIMQFUYw==", 377 | "requires": { 378 | "@types/node": "^20.8.9" 379 | } 380 | }, 381 | "create-require": { 382 | "version": "1.1.1", 383 | "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", 384 | "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", 385 | "dev": true 386 | }, 387 | "diff": { 388 | "version": "4.0.2", 389 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", 390 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", 391 | "dev": true 392 | }, 393 | "make-error": { 394 | "version": "1.3.6", 395 | "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", 396 | "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", 397 | "dev": true 398 | }, 399 | "prisma": { 400 | "version": "5.5.2", 401 | "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.5.2.tgz", 402 | "integrity": "sha512-WQtG6fevOL053yoPl6dbHV+IWgKo25IRN4/pwAGqcWmg7CrtoCzvbDbN9fXUc7QS2KK0LimHIqLsaCOX/vHl8w==", 403 | "devOptional": true, 404 | "requires": { 405 | "@prisma/engines": "5.5.2" 406 | } 407 | }, 408 | "ts-node": { 409 | "version": "10.9.1", 410 | "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", 411 | "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", 412 | "dev": true, 413 | "requires": { 414 | "@cspotcode/source-map-support": "^0.8.0", 415 | "@tsconfig/node10": "^1.0.7", 416 | "@tsconfig/node12": "^1.0.7", 417 | "@tsconfig/node14": "^1.0.0", 418 | "@tsconfig/node16": "^1.0.2", 419 | "acorn": "^8.4.1", 420 | "acorn-walk": "^8.1.1", 421 | "arg": "^4.1.0", 422 | "create-require": "^1.1.0", 423 | "diff": "^4.0.1", 424 | "make-error": "^1.1.1", 425 | "v8-compile-cache-lib": "^3.0.1", 426 | "yn": "3.1.1" 427 | } 428 | }, 429 | "typescript": { 430 | "version": "5.2.2", 431 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", 432 | "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", 433 | "dev": true 434 | }, 435 | "undici-types": { 436 | "version": "5.26.5", 437 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 438 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 439 | }, 440 | "v8-compile-cache-lib": { 441 | "version": "3.0.1", 442 | "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", 443 | "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", 444 | "dev": true 445 | }, 446 | "yn": { 447 | "version": "3.1.1", 448 | "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", 449 | "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", 450 | "dev": true 451 | } 452 | } 453 | } 454 | --------------------------------------------------------------------------------