Skip to content

Commit

Permalink
fix: express router missing (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
stone-jin authored Jan 13, 2021
1 parent 18d0fcd commit 30cd26c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/web-express/src/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class MidwayExpressFramework extends BaseFramework<
);

this.prioritySortRouters.forEach(prioritySortRouter => {
this.app.use(prioritySortRouter.router);
this.app.use(prioritySortRouter.prefix, prioritySortRouter.router);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { UserService } from '../service/user';
import { IMidwayExpressContext, IMidwayExpressRequest } from '../../../../../src';

@Provide()
@Controller('/')
@Controller('/api')
export class APIController {

@Inject()
Expand Down
10 changes: 5 additions & 5 deletions packages/web-express/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('/test/feature.test.ts', () => {

it('test setHeader decorator', async () => {
const result = await createHttpRequest(app)
.get('/set_header')
.get('/api/set_header')
.query({ name: 'harry' });
expect(result.status).toEqual(200);
expect(result.text).toEqual('bbb');
Expand All @@ -24,24 +24,24 @@ describe('/test/feature.test.ts', () => {
});

it('test get method with return value', async () => {
const result = await createHttpRequest(app).get('/').query({ name: 'harry' });
const result = await createHttpRequest(app).get('/api/').query({ name: 'harry' });
expect(result.status).toBe(201);
expect(result.text).toBe('hello world,harry');
});

it('test get method with redirect', async () => {
const result = await createHttpRequest(app).get('/login');
const result = await createHttpRequest(app).get('/api/login');
expect(result.status).toBe(302);
});

it('test get status 204', async () => {
const result = await createHttpRequest(app).get('/204');
const result = await createHttpRequest(app).get('/api/204');
console.log('result.status', result.status);
expect(result.status).toBe(204);
});

it('test get data with ctx.body', async () => {
const result = await createHttpRequest(app).get('/ctx-body');
const result = await createHttpRequest(app).get('/api/ctx-body');
expect(result.text).toEqual('ctx-body');
});
});
Expand Down

0 comments on commit 30cd26c

Please sign in to comment.