example: fix blog example (#79)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Yusuke Wada · committed by GitHub · parent 4c90444 · Browse files · 3 files·+26 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+26 added−9 removed
- tests:+9 added−2 removed
- other:+17 added−7 removed
Provenance
- Commit
1841a17- Tree
31283ab- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
4c90444
3 files changed+26 added−9 removed
modified:examples/blog/src/controller.test.ts+9 added-2 removed
21 unmodified lines222324252626272829303132333418 unmodified lines5354555657585960616 unmodified lines6869707167727374757677786 unmodified lines21 unmodified lines })
it('CRUD', async () => { let payload = JSON.stringify({ title: 'Morning', body: 'Good Morning' }) let req = new Request('http://localhost/posts', { method: 'POST', body: payload }) let req = new Request('http://localhost/posts', { method: 'POST', body: payload, headers: { 'Content-Type': 'application/json' }, }) let res = await app.dispatch(req) expect(res.status).toBe(201) let body = (await res.json()) as any const newPost = body['post'] as Post18 unmodified lines payload = JSON.stringify({ title: 'Night', body: 'Good Night' }) req = new Request(`https://localhost/posts/${post.id}`, { method: 'PUT', body: payload, headers: { 'Content-Type': 'application/json' }, }) res = await app.dispatch(req) expect(res.status).toBe(200) body = (await res.json()) as any6 unmodified lines post = body['post'] as Post expect(post.title).toBe('Night') expect(post.body).toBe('Good Night')
req = new Request(`https://localhost/posts/${post.id}`, { method: 'DELETE' }) req = new Request(`https://localhost/posts/${post.id}`, { method: 'DELETE', }) res = await app.dispatch(req) expect(res.status).toBe(200) body = (await res.json()) as any expect(body['ok']).toBeTruthy()6 unmodified linesmodified:examples/blog/package.json+5 added-6 removed
3 unmodified lines456789101189101112134 unmodified lines18192021242223242527262728293 unmodified lines "description": "", "main": "dist/worker.js", "scripts": { "test": "jest --verbose", "build": "rimraf tsc && wrangler build", "dev": "tsc && npm-run-all --parallel dev:*", "dev:tsc": "tsc --watch", "dev:wrangler": "wrangler dev" "build": "wrangler build", "dev": "miniflare" }, "author": "Yusuke Wada <yusuke@kamawada.com> (https://github.com/yusukebe)", "license": "MIT", "dependencies": {4 unmodified lines "@cloudflare/wrangler": "^1.19.7", "@types/jest": "^27.4.0", "jest": "^27.4.7", "jest-environment-miniflare": "^2.0.0", "npm-run-all": "^4.1.5", "miniflare": "2.2.0", "ts-jest": "^27.1.2", "ts-loader": "~8.2.0", "typescript": "^4.5.4", "webpack": "^5.65.0", "webpack": "~4.44.1", "webpack-cli": "^4.9.1" }}No newline at end of fileNo newline at end of filemodified:examples/blog/webpack.config.js+12 added-1 removed
1233456789101112131415module.exports = { target: 'webworker', entry: './dist/index.js', entry: './src/index.ts', module: { rules: [ { test: /\.ts$/, loader: 'ts-loader', }, ], }, resolve: { extensions: ['.ts', '.js'], },}