irrasoft-node-codegen
Advanced tools
Comparing version 0.0.101 to 0.0.102
{ | ||
"name": "irrasoft-node-codegen", | ||
"version": "0.0.101", | ||
"version": "0.0.102", | ||
"bin": { | ||
@@ -5,0 +5,0 @@ "codegen": "./bin/cli.js" |
import Router from 'koa-router'; | ||
import msgConfig from '@config/msg'; | ||
import { | ||
add, | ||
update, | ||
getAll, | ||
getById, | ||
delById | ||
} from '@{{api_version}}/services/{{name}}'; | ||
import Models from '@{{api_version}}/services/models'; | ||
@@ -15,8 +9,10 @@ const router = new Router({ | ||
const model = new Models('{{table}}'); | ||
router.get('/', async(ctx) => { // get all | ||
const model = await getAll(); | ||
if(model) { | ||
const result = await model.getAll(); | ||
if(result) { | ||
ctx.body = { | ||
status: 'success', | ||
data: model | ||
data: result | ||
}; | ||
@@ -33,7 +29,7 @@ }else { | ||
const id = ctx.params.id; | ||
const model = await getById(id); | ||
if(model[0]) { | ||
const result = await model.getById(id); | ||
if(result[0]) { | ||
ctx.body = { | ||
status: msgConfig.status.success, | ||
data: model[0] | ||
data: result[0] | ||
}; | ||
@@ -49,3 +45,3 @@ }else { | ||
router.post('/', async(ctx) => { // create | ||
const isCreated = await add(ctx.payload); | ||
const isCreated = await model.create(ctx.payload); | ||
@@ -65,3 +61,3 @@ if(isCreated) { | ||
router.put('/', async(ctx) => { // update | ||
const isUpdated = await update(ctx.payload); | ||
const isUpdated = await model.update(ctx.payload); | ||
@@ -82,3 +78,3 @@ if(isUpdated) { | ||
const id = ctx.params.id; | ||
const isDeleted = await delById(id); | ||
const isDeleted = await model.delById(id); | ||
if(isDeleted) { | ||
@@ -85,0 +81,0 @@ ctx.response.body = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15472
6
388