-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20c8619
commit 22c4d4c
Showing
41 changed files
with
673 additions
and
4,269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import express from 'express'; | ||
import routes from './routes'; | ||
|
||
const app = express(); | ||
|
||
const PORT = 3000; | ||
|
||
app.use('/', routes); | ||
|
||
app.listen(PORT, function() { | ||
console.log(`Listening on port ${PORT}`); | ||
}); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Router } from 'express'; | ||
|
||
import userRoutes from './user.routes'; | ||
|
||
const router = Router(); | ||
|
||
router.use(userRoutes.path, userRoutes.router); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Resource } from '../../src'; | ||
import { Request, Response } from 'express'; | ||
import { UserSchema } from '../schema'; | ||
|
||
const resource = new Resource('user', new UserSchema()); | ||
|
||
resource.onCreate(function(req: Request, res: Response) { | ||
console.log(req.url); | ||
res.json({ | ||
message: 'User Created.', | ||
result: null | ||
}); | ||
}); | ||
|
||
export default resource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export * from './user.schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ResourceSchema, define, input } from '../../src'; | ||
|
||
export class UserSchema extends ResourceSchema { | ||
constructor() { | ||
super(); | ||
} | ||
@define() | ||
@input() | ||
displayName: string = 'Default User'; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
{ | ||
"name": "epi", | ||
"version": "1.0.0", | ||
"description": "A express api documentor..", | ||
"main": "dist/lts.js", | ||
"types": "dist/index.d.ts", | ||
"repository": "https://github.com/akgurjar/express-api.git", | ||
"main": "index.js", | ||
"repository": "https://github.com/akgurjar/epi.git", | ||
"author": "Ashish Gurjar <[email protected]>", | ||
"license": "GPL-3.0", | ||
"license": "GPL-3.0-or-later", | ||
"private": false, | ||
"scripts": { | ||
"start": "webpack-dev-server", | ||
"build": "webpack", | ||
"lint": "tslint -p tsconfig.json" | ||
"start": "ts-node-dev ./demo/app.ts" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.3.3333" | ||
}, | ||
"devDependencies": { | ||
"html-webpack-plugin": "^3.2.0", | ||
"ts-loader": "^5.3.3", | ||
"tslint": "^5.12.1", | ||
"typescript": "^3.3.1", | ||
"webpack": "^4.29.0", | ||
"webpack-cli": "^3.2.1", | ||
"webpack-dev-server": "^3.1.14" | ||
"express": "^4.16.4", | ||
"ts-node-dev": "^1.0.0-pre.32", | ||
"tslint": "^5.13.0" | ||
} | ||
} |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
|
||
// export * from './lib/index'; | ||
// import { body, method } from './lib/index'; | ||
export * from './lib'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
import { schemaSymbol } from './helper'; | ||
|
||
interface Options { | ||
type?: 'boolean' | 'string' | 'number' | 'object' | 'array'; | ||
required?: boolean; | ||
} | ||
interface InputOptions extends Options { | ||
operations: 'create' | 'update'; | ||
} | ||
interface OutputOptions extends Options { | ||
operations: 'detail' | 'list'; | ||
} | ||
|
||
export function define(options?: Options) { | ||
console.log(options); | ||
return (target: any, propertyKey: PropertyKey) => { | ||
// define schema container if not present | ||
const propSchema = propertySchema(target, propertyKey); | ||
// if () {} | ||
if (!target.hasOwnProperty(propertyKey)) { | ||
Object.defineProperty(target, propertyKey, { enumerable: true, writable: true }); | ||
console.info('Define > ', target, propertyKey); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* @description This decorator mark a property as input when a resource is created or updated. | ||
* @param operations Input operations on which this property act as input. | ||
*/ | ||
export function input(options?: InputOptions) { | ||
console.log(options); | ||
return (target: any, propertyKey: PropertyKey) => { | ||
// define schema container if not present | ||
if (!target[schemaSymbol]) { | ||
Object.defineProperty(target, schemaSymbol, {enumerable: false, value: {}}); | ||
} | ||
if (!target.hasOwnProperty(propertyKey)) { | ||
Object.defineProperty(target, propertyKey, { enumerable: true, writable: true }); | ||
console.log('Input > ', target, propertyKey); | ||
} | ||
}; | ||
} | ||
export function output(options?: OutputOptions) { | ||
console.log(options); | ||
return (target: any, propertyKey: PropertyKey) => { | ||
// define schema container if not present | ||
if (!target[schemaSymbol]) { | ||
Object.defineProperty(target, schemaSymbol, {enumerable: false, value: {}}); | ||
} | ||
if (!target.hasOwnProperty(propertyKey)) { | ||
Object.defineProperty(target, propertyKey, { enumerable: true, writable: true }); | ||
console.log('Output > ', target, propertyKey); | ||
} | ||
}; | ||
} | ||
|
||
|
||
function propertySchema(target: any, propertyKey: PropertyKey) { | ||
const schema = target[schemaSymbol] || {}; | ||
if (!schema[propertyKey]) { | ||
schema[propertyKey] = {}; | ||
} | ||
// Init Schema Container | ||
if (!target[schemaSymbol]) { | ||
Object.defineProperty(target, schemaSymbol, {enumerable: false, value: schema}); | ||
} | ||
// | ||
return schema[propertyKey]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export const schemaSymbol: unique symbol = Symbol('Schema Container.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
export * from './types/index'; | ||
export * from './locations/index'; | ||
export * from './functions/index'; | ||
export * from './decorator'; | ||
export * from './schema'; | ||
export * from './resource'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.