Skip to content

Commit

Permalink
refactor(example): The previous examples were deleted and the new exa…
Browse files Browse the repository at this point in the history
…mple was given for CRUD operations.
  • Loading branch information
m-mdy-m committed Aug 20, 2024
1 parent 14154be commit a3e00bb
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 596 deletions.
2 changes: 2 additions & 0 deletions examples/CRUD/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
.npmrc
3 changes: 3 additions & 0 deletions examples/CRUD/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { g } from '../../lib/core/server';
g.load('router');
g.init();
9 changes: 9 additions & 0 deletions examples/CRUD/models/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"users": {
"user": {
"id": 1,
"name": "mahdi",
"role": "member"
}
}
}
72 changes: 72 additions & 0 deletions examples/CRUD/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions examples/CRUD/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "crud",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@types/cors": "^2.8.17",
"cors": "^2.8.5"
}
}
20 changes: 20 additions & 0 deletions examples/CRUD/router/crud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { exposed } from '../../../lib/core/decorators/exposed';
import { Delete, Get, Post, Put, Route } from '../../../lib/core/router';
import { Context } from '../../../lib/types/types';
import db from '../models/db.json';
@Route('/')
@exposed
class GetAllUser {
@Get()
get(ctx: Context) {
const users = JSON.stringify(db);
ctx.write(users);
ctx.end();
}
@Post()
post(ctx: Context) {}
@Delete()
del(ctx: Context) {}
@Put()
put(ctx: Context) {}
}
94 changes: 0 additions & 94 deletions examples/UserController.ts

This file was deleted.

9 changes: 0 additions & 9 deletions examples/app/app.ts

This file was deleted.

38 changes: 0 additions & 38 deletions examples/app/controller.ts

This file was deleted.

31 changes: 0 additions & 31 deletions examples/app/router/router.ts

This file was deleted.

22 changes: 0 additions & 22 deletions examples/app/router/test.ts

This file was deleted.

Loading

0 comments on commit a3e00bb

Please sign in to comment.