Skip to content

Commit

Permalink
fix: add default env for egg module (midwayjs#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Aug 24, 2020
1 parent 1e558f5 commit 41272d0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const Controller = require('egg').Controller;
class HomeController extends Controller {
async getMethod() {
const { ctx } = this;
ctx.set('x-bbbb', 'ccccccc');
ctx.type = 'html';
ctx.body = 'Hello World';
}
async getQueryMethod() {
const { ctx } = this;
ctx.body = {
query: ctx.query
query: ctx.query,
};
}
async postMethod() {
Expand All @@ -21,7 +22,7 @@ class HomeController extends Controller {
async postBodyMethod() {
const { ctx } = this;
ctx.body = {
body: ctx.request.body
body: ctx.request.body,
};
}
async buffer() {
Expand Down
1 change: 1 addition & 0 deletions packages/egg-layer/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('/test/index.test.ts', () => {
request(app)
.get('/get')
.expect('Content-Type', 'text/html; charset=utf-8')
.expect('x-bbbb', 'ccccccc')
.expect(/Hello World/)
.expect(200, done);
});
Expand Down
3 changes: 3 additions & 0 deletions packages/serverless-aws-starter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { AWSRuntime } from './runtime';
export { asyncWrapper } from '@midwayjs/runtime-engine';

export const start = async () => {
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production';
}
const runtimeEngine = new BaseRuntimeEngine();
runtimeEngine.add(engine => {
engine.addBaseRuntime(new AWSRuntime());
Expand Down
3 changes: 3 additions & 0 deletions packages/serverless-fc-starter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export * from './runtime';
let bootstrap;

export const start = async (options: any = {}) => {
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production';
}
bootstrap = new BaseBootstrap(
Object.assign(
{
Expand Down
3 changes: 3 additions & 0 deletions packages/serverless-scf-starter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export { asyncWrapper } from '@midwayjs/runtime-engine';
let bootstrap;

export const start = async (options: any = {}) => {
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production';
}
bootstrap = new BaseBootstrap(
Object.assign(
{
Expand Down

0 comments on commit 41272d0

Please sign in to comment.