Skip to content

Commit

Permalink
refactor!: update repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 9, 2022
1 parent 4e053e6 commit 5dd59f1
Show file tree
Hide file tree
Showing 15 changed files with 1,382 additions and 2,739 deletions.
43 changes: 10 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,16 @@ on:

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [14]
runs-on: ubuntu-latest

steps:
- uses: actions/setup-node@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: checkout
uses: actions/checkout@master

- name: cache node_modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn

- name: Lint
run: yarn lint

- name: Build
run: yarn build

- name: Test
run: yarn jest

- name: Coverage
uses: codecov/codecov-action@v1
node-version: '16'
cache: yarn
- run: yarn install
- run: yarn lint
- run: yarn build
- run: yarn test --coverage
- uses: codecov/codecov-action@v2
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,38 @@
"dist"
],
"scripts": {
"build": "siroc build",
"dev": "jiti test/playground",
"lint": "eslint --ext ts .",
"profile": "0x -o -D .profile -P 'autocannon -c 100 -p 10 -d 40 http://localhost:$PORT' ./hello.js",
"release": "yarn test && yarn build && standard-version && npm publish && git push --follow-tags",
"test": "yarn lint && jest"
"build": "unbuild",
"dev": "jiti ./playground/index.ts",
"lint": "eslint --ext ts,mjs,cjs .",
"profile": "0x -o -D .profile -P 'autocannon -c 100 -p 10 -d 40 http://localhost:$PORT' ./playground/server.cjs",
"release": "yarn lint && yarn test && yarn build && standard-version && npm publish && git push --follow-tags",
"test": "vitest run"
},
"dependencies": {
"cookie": "^0.4.2",
"destr": "^1.1.0",
"ufo": "^0.7.11"
},
"devDependencies": {
"0x": "latest",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/cookie": "latest",
"@types/express": "latest",
"@types/jest": "latest",
"@types/node": "latest",
"@types/supertest": "latest",
"autocannon": "latest",
"c8": "latest",
"connect": "latest",
"cookie-es": "latest",
"destr": "latest",
"eslint": "latest",
"express": "latest",
"get-port": "^5.0.0",
"jest": "latest",
"jiti": "latest",
"listhen": "latest",
"siroc": "latest",
"standard-version": "latest",
"supertest": "latest",
"ts-jest": "latest",
"typescript": "latest",
"ufo": "latest"
"unbuild": "latest",
"vitest": "latest"
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion hello.js → playground/server.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { createServer } = require('http')
const { createApp } = require('./dist')
const { createApp } = require('..')

const app = createApp()

Expand Down
1 change: 1 addition & 0 deletions test/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import supertest, { SuperTest, Test } from 'supertest'
import { describe, it, expect, beforeEach } from 'vitest'
import { createApp, App } from '../src'

describe('app', () => {
Expand Down
6 changes: 4 additions & 2 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { describe, it, expect } from 'vitest'
import { promisifyHandle } from '../src'

// import { sendReq } from './utils'
const sendReq = (_: any) => {}

describe.skip('promisifyHandle', () => {
test('handles exception', async () => {
it('handles exception', async () => {
const h = promisifyHandle(() => { throw new Error('oops') })
await expect(sendReq(h)).rejects.toThrow('oops')
})

test('handles exception (promise)', async () => {
it('handles exception (promise)', async () => {
const h = promisifyHandle(() => { return Promise.reject(new Error('oops')) })
await expect(sendReq(h)).rejects.toThrow('oops')
})
Expand Down
1 change: 1 addition & 0 deletions test/body.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import supertest, { SuperTest, Test } from 'supertest'
import { describe, it, expect, beforeEach } from 'vitest'
import { createApp, App, useBody, useRawBody } from '../src'

describe('', () => {
Expand Down
1 change: 1 addition & 0 deletions test/cookie.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import supertest, { SuperTest, Test } from 'supertest'
import { describe, it, expect, beforeEach } from 'vitest'
import { createApp, App } from '../src'
import { setCookie, useCookie, useCookies } from '../src/utils/cookie'

Expand Down
3 changes: 2 additions & 1 deletion test/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Server } from 'http'
import supertest, { SuperTest, Test } from 'supertest'
import getPort from 'get-port'
import { describe, it, expect, beforeEach, afterEach, fn } from 'vitest'

import { createApp, App } from '../src'

; (global.console.error as any) = jest.fn()
; (global.console.error as any) = fn()

describe('server', () => {
let app: App
Expand Down
5 changes: 3 additions & 2 deletions test/error.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import supertest, { SuperTest, Test } from 'supertest'
import { describe, it, expect, beforeEach, fn } from 'vitest'
import { createApp, App, createError } from '../src'

; (global.console.error as any) = jest.fn()
const consoleMock = (global.console.error as any) = fn()

describe('error', () => {
let app: App
Expand Down Expand Up @@ -47,7 +48,7 @@ describe('error', () => {
})

it('can send runtime error', async () => {
jest.clearAllMocks()
consoleMock.mockReset()

app.use('/', () => {
throw createError({
Expand Down
2 changes: 1 addition & 1 deletion test/integrations.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from 'express'
import createConnectApp from 'connect'

import { describe, it, expect, beforeEach } from 'vitest'
import supertest, { SuperTest, Test } from 'supertest'
import { createApp, App } from '../src'

Expand Down
5 changes: 3 additions & 2 deletions test/lazy.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import supertest, { SuperTest, Test } from 'supertest'
import { createApp, App } from '../src'
import { describe, it, expect, beforeEach, fn } from 'vitest'

;(global.console.error as any) = jest.fn()
import { createApp, App } from '../src'
(global.console.error as any) = fn()

describe('lazy loading', () => {
let app: App
Expand Down
1 change: 1 addition & 0 deletions test/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import supertest, { SuperTest, Test } from 'supertest'
import { describe, it, expect, beforeEach } from 'vitest'
import { createApp, App, sendRedirect, useBase, useQuery, useMethod, assertMethod } from '../src'

describe('', () => {
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"strict": true,
"declaration": true,
"types": [
"node",
"jest"
"node"
]
},
"include": [
Expand Down
Loading

0 comments on commit 5dd59f1

Please sign in to comment.