Skip to content

Commit

Permalink
feat(service): export all the constants (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
Repraance authored Sep 24, 2021
1 parent 50ab06d commit fee965d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
10 changes: 1 addition & 9 deletions packages/service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,4 @@ export { matchRoutes } from '@shuvi/router';
export { shuvi, Shuvi } from './shuvi';
export { IApi, Api, getApi, PluginApi, IApiConfig, IConfig } from './api';
export { ProjectBuilder } from './project';
export {
BUNDLER_TARGET_CLIENT,
BUNDLER_TARGET_SERVER,
IDENTITY_RUNTIME_PUBLICPATH,
PHASE_PRODUCTION_BUILD,
PHASE_PRODUCTION_SERVER,
PHASE_DEVELOPMENT_SERVER,
PHASE_INSPECT_WEBPACK
} from './constants';
export * from './constants';
1 change: 0 additions & 1 deletion packages/shuvi/src/constants.ts

This file was deleted.

20 changes: 10 additions & 10 deletions test/e2e/api-routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('apiRoutes development', () => {
test('should return 404 for undefined path', async () => {
try {
await got.get(ctx.url('/api/not/unexisting/page/really'));
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toBe(404);
}
});
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('apiRoutes development', () => {
test('should return custom error', async () => {
try {
await got.get(ctx.url('/api/error'));
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toEqual(500);
expect(JSON.parse(error.response.body)).toEqual({
error: 'Server error!'
Expand All @@ -111,7 +111,7 @@ describe('apiRoutes development', () => {
test('should throw Internal Server Error', async () => {
try {
await got.get(ctx.url('/api/user-error'));
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toEqual(500);
expect(error.response.body).toContain('User error');
}
Expand All @@ -120,7 +120,7 @@ describe('apiRoutes development', () => {
test('should throw Internal Server Error (async)', async () => {
try {
await got.get(ctx.url('/api/user-error-async'));
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toEqual(500);
expect(error.response.body).toContain('User error');
}
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('apiRoutes development', () => {
},
body: `{"message":Invalid"}`
});
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toEqual(400);
expect(error.response.body).toContain('Invalid JSON');
}
Expand All @@ -209,7 +209,7 @@ describe('apiRoutes development', () => {
},
body: JSON.stringify(json)
});
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toEqual(413);
expect(error.response.body).toContain('Body exceeded 1mb limit');
}
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('apiRoutes development', () => {
test('should show friendly error for invalid redirect', async () => {
try {
await got.get(ctx.url('/api/redirect-error'));
} catch (error) {
} catch (error: any) {
expect(error.response.body).toContain(
`Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').`
);
Expand All @@ -291,7 +291,7 @@ describe('apiRoutes development', () => {
test('should show friendly error in case of passing null as first argument redirect', async () => {
try {
await got.get(ctx.url('/api/redirect-null'));
} catch (error) {
} catch (error: any) {
expect(error.response.body).toContain(
`Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').`
);
Expand All @@ -310,7 +310,7 @@ describe('apiRoutes development', () => {
await got(ctx.url('/api/redirect-307'), {
followRedirect: true
});
} catch (error) {
} catch (error: any) {
expect(error.response.requestUrl).toContain('/api/redirect-307');
expect(error.response.url).toContain('/login');
}
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('apiRoutes development', () => {
test('should 404 on optional dynamic api page', async () => {
try {
await got(ctx.url('/api/blog/543/comment'));
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toEqual(404);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/public-dir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Public Dir', () => {
// folder
try {
await got.get(ctx.url('/_shuvi/nest'), { responseType: 'json' });
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toBe(404);
}
});
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('Public Dir', () => {
// folder
try {
await got.get(ctx.url('/_shuvi/nest'), { responseType: 'json' });
} catch (error) {
} catch (error: any) {
expect(error.response.statusCode).toBe(404);
}
});
Expand Down

0 comments on commit fee965d

Please sign in to comment.