Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor with typescript to support cjs ane esm both #5328

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "eslint-config-egg"
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
29 changes: 0 additions & 29 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

68 changes: 0 additions & 68 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: CI

on:
push:
branches: [ master, 2.x, 1.x ]

branches: [ master ]
pull_request:
branches: [ master, 2.x, 1.x ]
branches: [ master ]

jobs:
Job:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '14, 16, 18, 20, 22'
install: 'npm i -g npminstall && npminstall'
version: '18.19.0, 18, 20, 22'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Release

on:
push:
branches: [ master, 2.x, 1.x ]
branches: [ master ]

jobs:
release:
Expand All @@ -10,5 +11,3 @@ jobs:
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
install: 'npm install --legacy-peer-deps --no-package-lock --no-fund'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ site/dist
.umi-production
.vercel
package-lock.json
.tshy*
dist
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ English | [简体中文](./README.zh-CN.md)
[![Known Vulnerabilities](https://snyk.io/test/npm/egg/badge.svg?style=flat-square)](https://snyk.io/test/npm/egg)
[![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/eggjs?style=flat-square)](https://opencollective.com/eggjs)


## Features

- Built-in Process Management
Expand Down Expand Up @@ -62,5 +61,4 @@ To become a contributor, please follow our [contributing guide](CONTRIBUTING.md)

[MIT](LICENSE)


[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feggjs%2Fegg.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_large)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feggjs%2Fegg.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_large)
13 changes: 7 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
## 快速开始

```bash
$ mkdir showcase && cd showcase
$ npm init egg --type=simple
$ npm install
$ npm run dev
$ open http://localhost:7001
mkdir showcase && cd showcase
npm init egg --type=simple
npm install
npm run dev

open http://localhost:7001
```

## 文档
Expand All @@ -45,7 +46,7 @@ $ open http://localhost:7001

## 贡献代码

请告知我们可以为你做些什么,不过在此之前,请检查一下是否有[已经存在的Bug或者意见](https://github.com/eggjs/egg/issues)。
请告知我们可以为你做些什么,不过在此之前,请检查一下是否有[已经存在的 Bug 或者意见](https://github.com/eggjs/egg/issues)。

如果你是一个代码贡献者,请参考[代码贡献规范](CONTRIBUTING.md)。

Expand Down
11 changes: 0 additions & 11 deletions agent.js

This file was deleted.

3 changes: 0 additions & 3 deletions app/middleware/body_parser.js

This file was deleted.

3 changes: 0 additions & 3 deletions app/middleware/override_method.js

This file was deleted.

31 changes: 0 additions & 31 deletions app/middleware/site_file.js

This file was deleted.

7 changes: 0 additions & 7 deletions config/config.local.js

This file was deleted.

8 changes: 0 additions & 8 deletions config/config.unittest.js

This file was deleted.

37 changes: 11 additions & 26 deletions index.d.ts → index-old.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import accepts = require('accepts');
import { AsyncLocalStorage } from 'async_hooks';
import { EventEmitter } from 'events'
import { EventEmitter } from 'events';
import { Readable } from 'stream';
import { Socket } from 'net';
import { IncomingMessage, ServerResponse } from 'http';
Expand Down Expand Up @@ -65,10 +65,10 @@ declare module 'egg' {
export interface EggHttpClient extends EventEmitter {
request<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
request<T = any>(url: HttpClientRequestURL, options: RequestOptionsOld | HttpClientRequestOptions):
Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
curl<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
curl<T = any>(url: HttpClientRequestURL, options: RequestOptionsOld | HttpClientRequestOptions):
Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
}

interface EggHttpConstructor {
Expand Down Expand Up @@ -245,20 +245,6 @@ declare module 'egg' {
type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
type IgnoreOrMatch = IgnoreItem | IgnoreItem[];

/** logger config of egg */
export interface EggLoggerConfig extends RemoveSpecProp<EggLoggersOptions, 'type'> {
/** custom config of coreLogger */
coreLogger?: Partial<EggLoggerOptions>;
/** allow debug log at prod, defaults to `false` */
allowDebugAtProd?: boolean;
/** disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`. */
disableConsoleAfterReady?: boolean;
/** using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to `false`. e.g.: logger will set 1.456ms instead of 1ms. */
enablePerformanceTimer?: boolean;
/** using the app logger instead of EggContextLogger, defaults to `false` */
enableFastContextLogger?: boolean;
}

/** Custom Loader Configuration */
export interface CustomLoaderConfig extends RemoveSpecProp<FileLoaderOption, 'inject' | 'target'> {
/**
Expand Down Expand Up @@ -371,7 +357,6 @@ declare module 'egg' {
* @property {String} agentLogName - file name of agent worker log
* @property {Object} coreLogger - custom config of coreLogger
* @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
* @property {Boolean} enablePerformanceTimer - using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to false. e.g.: logger will set 1.456ms instead of 1ms.
* @property {Boolean} enableFastContextLogger - using the app logger instead of EggContextLogger, defaults to false
*/
logger: EggLoggerConfig;
Expand Down Expand Up @@ -738,13 +723,13 @@ declare module 'egg' {

/**
* Get current execute ctx async local storage
* @returns {AsyncLocalStorage} localStorage - store current execute Context
* @return {AsyncLocalStorage} localStorage - store current execute Context
*/
get ctxStorage(): AsyncLocalStorage<Context>;

/**
* Get current execute ctx, maybe undefined
* @returns {Context} ctx - current execute Context
* @return {Context} ctx - current execute Context
*/
get currentContext(): Context;
}
Expand Down Expand Up @@ -1016,7 +1001,7 @@ declare module 'egg' {
* // get other fields
* console.log(stream.fields);
* ```
* @method Context#getFileStream
* @function Context#getFileStream
* @param {Object} options
* @return {ReadStream} stream
* @since 1.0.0
Expand Down Expand Up @@ -1067,7 +1052,7 @@ declare module 'egg' {
export interface IHelper extends PlainObject, BaseContextClass {
/**
* Generate URL path(without host) for route. Takes the route name and a map of named params.
* @method Helper#pathFor
* @function Helper#pathFor
* @param {String} name - Router Name
* @param {Object} params - Other params
*
Expand All @@ -1083,7 +1068,7 @@ declare module 'egg' {

/**
* Generate full URL(with host) for route. Takes the route name and a map of named params.
* @method Helper#urlFor
* @function Helper#urlFor
* @param {String} name - Router name
* @param {Object} params - Other params
* @example
Expand Down Expand Up @@ -1168,7 +1153,7 @@ declare module 'egg' {
ignoreWarning?: boolean;
}

export function start(options?: StartOptions): Promise<Application>
export function start(options?: StartOptions): Promise<Application>;

/**
* Powerful Partial, Support adding ? modifier to a mapped property in deep level
Expand All @@ -1180,8 +1165,8 @@ declare module 'egg' {
*/
export type PowerPartial<T> = {
[U in keyof T]?: T[U] extends object
? PowerPartial<T[U]>
: T[U]
? PowerPartial<T[U]>
: T[U]
};

// send data can be number|string|boolean|object but not Set|Map
Expand Down
Loading
Loading