generated from helsingborg-stad/gdi-template
-
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.
* copy of @helsingborg-stad/gdi-api-node * removed dependency to @helsingborg-stad/gdi-api-node
- Loading branch information
Showing
105 changed files
with
1,687 additions
and
151 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,13 @@ | ||
import { StatusCodes } from 'http-status-codes' | ||
import request from 'supertest' | ||
import { createTestApp } from './test-utils' | ||
|
||
|
||
describe('GET /missing/resource', () => { | ||
it('gives 404 not found', () => createTestApp() | ||
.run(async server => { | ||
const { status } = await request(server) | ||
.post('/missing/resource') | ||
expect(status).toBe(StatusCodes.NOT_FOUND) | ||
})) | ||
}) |
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,26 @@ | ||
import { StatusCodes } from 'http-status-codes' | ||
import request from 'supertest' | ||
import { createTestApp, registerTestApi } from './test-utils' | ||
|
||
describe('POST /api/v1/test-operation', () => { | ||
it('works just fine', () => createTestApp() | ||
.use(registerTestApi({ | ||
testOperation: async (ctx) => { | ||
const { request: { body: { query } } } = ctx as any | ||
ctx.body = { | ||
id: '1234', | ||
answer: `Please google "${query}"`, | ||
} | ||
}, | ||
})) | ||
.run(async server => { | ||
const { status, body } = await request(server) | ||
.post('/api/v1/test-operation') | ||
.send({ query: 'what time is it?' }) | ||
expect(status).toBe(StatusCodes.OK) | ||
expect(body).toMatchObject({ | ||
id: '1234', | ||
answer: 'Please google "what time is it?"', | ||
}) | ||
})) | ||
}) |
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,34 @@ | ||
import { StatusCodes } from 'http-status-codes' | ||
import request from 'supertest' | ||
import { createTestApp } from './test-utils' | ||
|
||
describe('POST /api/v1/test-operation', () => { | ||
it('can be extended with downstream middleware', () => createTestApp() | ||
.use(({ extend }) => { | ||
extend({ | ||
// we extend by composing in additional middleware that should be combined | ||
// with subsequent koa api handlers | ||
compose: mv => (ctx, next) => { | ||
ctx.downstreamMessage = 'hello downstream' | ||
return mv(ctx, next) | ||
}, | ||
}) | ||
}) | ||
.use(({ registerKoaApi }) => registerKoaApi({ | ||
testOperation: async (ctx) => { | ||
ctx.body = { | ||
id: '1234', | ||
answer: ctx.downstreamMessage, | ||
} | ||
}, | ||
})) | ||
.run(async server => { | ||
const { status, body } = await request(server) | ||
.post('/api/v1/test-operation') | ||
.send({ query: '?' }) | ||
expect(status).toBe(StatusCodes.OK) | ||
expect(body).toMatchObject({ | ||
answer: 'hello downstream', | ||
}) | ||
})) | ||
}) |
Oops, something went wrong.