File tree Expand file tree Collapse file tree 7 files changed +25
-18
lines changed
Expand file tree Collapse file tree 7 files changed +25
-18
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ node_modules
44scratchpad.js
55testCoverage
66examples /* /* .db
7- examples /express-es7 / build
7+ examples /* / dist
88examples /** /package-lock.json
99* .iml
1010* .DS_Store
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ export default (router: KoaRouter) => {
7373 }
7474
7575 if ( ctx . query . orderBy ) {
76- query . orderBy ( ctx . query . orderBy )
76+ query . orderBy ( takeFirst ( ctx . query . orderBy ) )
7777 }
7878
7979 if ( ctx . query . withPetCount ) {
@@ -239,3 +239,7 @@ export default (router: KoaRouter) => {
239239 ctx . body = actors
240240 } )
241241}
242+
243+ function takeFirst < T > ( item : T | ReadonlyArray < T > ) : T {
244+ return Array . isArray ( item ) ? item [ 0 ] : item
245+ }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ app.listen(port, () => {
3737async function errorHandler ( ctx : Context , next : ( ) => Promise < any > ) {
3838 try {
3939 await next ( )
40- } catch ( err ) {
40+ } catch ( err : any ) {
4141 if ( err instanceof ValidationError ) {
4242 ctx . status = 400
4343 ctx . body = {
Original file line number Diff line number Diff line change @@ -40,7 +40,11 @@ const req = axios.create({
4040 await addPersonToMovieAsActor ( departed , matt )
4141 await removePersonFromMovie ( departed , matt )
4242} ) ( ) . catch ( ( err ) => {
43- console . error ( 'error:' , err . response . status , err . response . data )
43+ if ( err . response ) {
44+ console . error ( 'error:' , err . response . status , err . response . data )
45+ } else {
46+ console . error ( 'error:' , err )
47+ }
4448} )
4549
4650async function inserPersonWithRelations ( ) {
Original file line number Diff line number Diff line change 11{
2- "name" : " objection-example-koa" ,
3- "version" : " 2 .0.0" ,
4- "description" : " Objection.js koa example" ,
2+ "name" : " objection-example-koa-ts " ,
3+ "version" : " 3 .0.0" ,
4+ "description" : " Objection.js koa typescript example" ,
55 "main" : " app.js" ,
66 "scripts" : {
77 "migrate" : " knex migrate:latest" ,
8- "start" : " npm run migrate && ts- node app"
8+ "start" : " npm run migrate && rm -rf dist && tsc && node dist/ app.js "
99 },
1010 "engines" : {
1111 "node" : " >=8.0.0"
1414 "license" : " MIT" ,
1515 "dependencies" : {
1616 "axios" : " ^0.19.0" ,
17- "knex" : " ^0.20.3 " ,
17+ "knex" : " ^0.95.13 " ,
1818 "koa" : " ^2.11.0" ,
1919 "koa-bodyparser" : " ^4.2.1" ,
2020 "koa-router" : " ^7.4.0" ,
21- "objection" : " ^2.1.0 " ,
22- "sqlite3" : " ^4.1.0 "
21+ "objection" : " ^3.0.0-rc.4 " ,
22+ "sqlite3" : " ^5.0.2 "
2323 },
2424 "devDependencies" : {
2525 "@types/koa" : " ^2.11.0" ,
2626 "@types/koa-bodyparser" : " ^4.3.0" ,
2727 "@types/koa-router" : " ^7.0.42" ,
28- "ts-node" : " ^8.5.4" ,
29- "typescript" : " 3.7.2"
28+ "typescript" : " 4.4.4"
3029 }
3130}
Original file line number Diff line number Diff line change 1414 "allowJs" : true ,
1515 "target" : " esnext" ,
1616 "rootDir" : " ./" ,
17- "outDir" : " lib "
17+ "outDir" : " dist "
1818 }
1919}
Original file line number Diff line number Diff line change 11{
22 "name" : " objection-example-koa" ,
3- "version" : " 2 .0.0" ,
3+ "version" : " 3 .0.0" ,
44 "description" : " Objection.js koa example" ,
55 "main" : " app.js" ,
66 "scripts" : {
1414 "license" : " MIT" ,
1515 "dependencies" : {
1616 "axios" : " ^0.19.0" ,
17- "knex" : " ^0.20.3 " ,
17+ "knex" : " ^0.95.13 " ,
1818 "koa" : " ^2.11.0" ,
1919 "koa-bodyparser" : " ^4.2.1" ,
2020 "koa-router" : " ^7.4.0" ,
21- "objection" : " ^2.1.0 " ,
22- "sqlite3" : " ^4.1.0 "
21+ "objection" : " 3.0.0-rc.4 " ,
22+ "sqlite3" : " ^5.0.2 "
2323 }
2424}
You can’t perform that action at this time.
0 commit comments