Skip to content

Commit

Permalink
Merge pull request #295 from frouriojs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
solufa authored Aug 3, 2023
2 parents 0479e00 + bb50c1e commit 4e8aaf6
Show file tree
Hide file tree
Showing 117 changed files with 9,328 additions and 6,312 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
id: yarn-cache
id: npm-cache
with:
path: "node_modules"
key: ${{ runner.os }}-node-v${{ matrix.node-version }}-yarn-${{ hashFiles('yarn.lock') }}
- run: yarn --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: yarn lint
key: ${{ runner.os }}-node-v${{ matrix.node-version }}-npm-${{ hashFiles('package-lock.json') }}
- run: npm install
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm run lint
if: matrix.os != 'windows-latest'
- run: yarn typecheck
- run: yarn build
- run: yarn test
- run: npm run typecheck
- run: npm run build
- run: npm test

release:
runs-on: ubuntu-latest
Expand All @@ -44,13 +44,13 @@ jobs:
node-version: 18
registry-url: "https://registry.npmjs.org"
- uses: actions/cache@v2
id: yarn-cache
id: npm-cache
with:
path: "node_modules"
key: ${{ runner.os }}-node-v18-yarn-${{ hashFiles('yarn.lock') }}
- run: yarn --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: yarn build
key: ${{ runner.os }}-node-v18-npm-${{ hashFiles('package-lock.json') }}
- run: npm install
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm run build
- run: |
VERSION="$(node -e 'console.log(process.argv[1].match(/^refs\/tags\/v(\d+\.\d+\.\d+)$/)[1])' "${{ github.ref }}")"
node -e 'console.log(JSON.stringify({...require("./package.json"),version:process.argv[1]}, null, 2))' "$VERSION" | tee ./tmp-package.json
Expand Down
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"eslint.run": "onSave",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"editor.codeActionsOnSave": { "source.fixAll.eslint": true },
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.referencesCodeLens.enabled": true,
"files.eol": "\n",
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Solufa <[email protected]>
Copyright (c) 2020-present, Solufa <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
<a href="https://www.npmjs.com/package/frourio">
<img src="https://img.shields.io/npm/dm/frourio" alt="npm download" />
</a>
<a href="https://github.com/frouriojs/frourio/actions?query=workflow%3A%22Node.js+CI%22">
<img src="https://github.com/frouriojs/frourio/workflows/Node.js%20CI/badge.svg?branch=main" alt="Node.js CI" />
</a>
<a href="https://lgtm.com/projects/g/frouriojs/frourio/context:javascript">
<img src="https://img.shields.io/lgtm/grade/javascript/g/frouriojs/frourio.svg" alt="Language grade: JavaScript" />
</a>
</div>

<p align="center">Fast and type-safe full stack framework, for TypeScript</p>
Expand Down
4 changes: 2 additions & 2 deletions __test__/build.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aspidaBuild from 'aspida/dist/buildTemplate';
import aspidaBuild from 'aspida/dist/cjs/buildTemplate';
import fs from 'fs';
import { version } from '../package.json';
import { run } from '../src';
Expand Down Expand Up @@ -34,7 +34,7 @@ test('build', () => {
baseURL: '',
trailingSlash: false,
outputEachDir: false,
outputMode: 'all'
outputMode: 'all',
});
expect(target.text).toBe(fs.readFileSync(target.filePath, 'utf8').replace(/\r/g, ''));
});
Expand Down
90 changes: 45 additions & 45 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ beforeEach(() => {
validateOrReject: (instance, options): Promise<void> => {
subServerValidateOrRejectCallCount++;
return validateOrReject(instance, options);
}
}).listen({ port: subPort })
},
}).listen({ port: subPort }),
]);
});

Expand All @@ -55,7 +55,7 @@ test('GET: 200', () =>
id: '1',
disable: 'false',
bool: true,
boolArray: [false, true]
boolArray: [false, true],
},
{
requiredNum: 2,
Expand All @@ -66,12 +66,12 @@ test('GET: 200', () =>
bool: false,
optionalBool: true,
boolArray: [],
optionalBoolArray: [true, false, false]
}
optionalBoolArray: [true, false, false],
},
].map(query =>
Promise.all([
expect(client.$get({ query })).resolves.toEqual(query),
expect(fetchClient.$get({ query })).resolves.toEqual(query)
expect(fetchClient.$get({ query })).resolves.toEqual(query),
])
)
));
Expand Down Expand Up @@ -113,38 +113,38 @@ test('GET: 400', () =>
id: '1',
disable: 'no boolean',
bool: false,
boolArray: []
boolArray: [],
},
{
requiredNum: 0,
requiredNumArr: [],
id: '2',
disable: 'true',
bool: false,
boolArray: ['no boolean']
boolArray: ['no boolean'],
},
{
requiredNum: 0,
requiredNumArr: ['no number'],
id: '3',
disable: 'true',
bool: false,
boolArray: []
boolArray: [],
},
{
requiredNum: 1,
requiredNumArr: [1, 2],
id: 'no number',
disable: 'true',
bool: false,
boolArray: []
}
boolArray: [],
},
].map(query =>
Promise.all([
// @ts-expect-error
expect(client.get({ query })).rejects.toHaveProperty('response.status', 400),
// @ts-expect-error
expect(fetchClient.get({ query })).rejects.toHaveProperty('response.status', 400)
expect(fetchClient.get({ query })).rejects.toHaveProperty('response.status', 400),
])
)
));
Expand Down Expand Up @@ -172,7 +172,7 @@ test('POST: formdata', async () => {
form1.append('file', fileST1);
const res1 = await axios.post(baseURL, form1, {
params: { requiredNum: 0, id: '1', disable: 'true', bool: false },
headers: form1.getHeaders()
headers: form1.getHeaders(),
});
expect(res1.data.port).toBe(port);
expect(res1.data.fileName).toBe(fileName);
Expand All @@ -186,7 +186,7 @@ test('POST: formdata', async () => {
form2.append('file', fileST2);
const res2 = await axios.post(subBaseURL, form2, {
params: { requiredNum: 0, id: '1', disable: 'true', bool: false },
headers: form2.getHeaders()
headers: form2.getHeaders(),
});
expect(res2.data.port).toBe(port);
expect(res2.data.fileName).toBe(fileName);
Expand All @@ -208,9 +208,9 @@ test('PUT: zod validations', async () => {
id: '1',
disable: 'true',
bool: false,
boolArray: []
boolArray: [],
},
body: { port: 3000 as any }
body: { port: 3000 as any },
})
).rejects.toHaveProperty('response.status', 400),
expect(
Expand All @@ -221,11 +221,11 @@ test('PUT: zod validations', async () => {
id: '1',
disable: 'true',
bool: 1 as any,
boolArray: []
boolArray: [],
},
body: { port }
body: { port },
})
).rejects.toHaveProperty('response.status', 400)
).rejects.toHaveProperty('response.status', 400),
]);

await expect(
Expand All @@ -236,9 +236,9 @@ test('PUT: zod validations', async () => {
id: '1',
disable: 'true',
bool: false,
boolArray: []
boolArray: [],
},
body: { port }
body: { port },
})
).resolves.toHaveProperty('status', 201);
});
Expand All @@ -254,7 +254,7 @@ test('POST: multi file upload', async () => {
form.append('files', fileST);
form.append('files', fileST);
const res = await axios.post(`${baseURL}/multiForm`, form, {
headers: form.getHeaders()
headers: form.getHeaders(),
});

expect(res.data).toEqual({
Expand All @@ -263,7 +263,7 @@ test('POST: multi file upload', async () => {
name: -1,
icon: -1,
vals: 1,
files: 2
files: 2,
});
});

Expand All @@ -277,7 +277,7 @@ test('POST: 400', async () => {

await expect(
axios.post(`${baseURL}/multiForm`, form, {
headers: form.getHeaders()
headers: form.getHeaders(),
})
).rejects.toHaveProperty('response.status', 400);
});
Expand All @@ -289,9 +289,9 @@ test('POST: nested validation', async () => {
name: 'foo',
location: {
country: 'JP',
stateProvince: 'Tokyo'
}
}
stateProvince: 'Tokyo',
},
},
});
expect(res1.status).toBe(204);

Expand All @@ -305,11 +305,11 @@ test('POST: nested validation', async () => {
stateProvince: 'Tokyo',
extra1: {
extra1a: 'bar',
extra1b: 'baz'
}
extra1b: 'baz',
},
},
extra2: 'qux'
} as any
extra2: 'qux',
} as any,
});
expect(res2.status).toBe(204);
});
Expand All @@ -323,16 +323,16 @@ test('POST: 400 (nested validation)', async () => {
name: 'foo',
location: {
country: 'JP',
stateProvince: 'Tokyo'
}
} as any
stateProvince: 'Tokyo',
},
} as any,
})
).rejects.toHaveProperty('response.status', 400);

// location is missing
await expect(
client.users.post({
body: { id: 123, name: 'foo' } as any
body: { id: 123, name: 'foo' } as any,
})
).rejects.toHaveProperty('response.status', 400);

Expand All @@ -344,9 +344,9 @@ test('POST: 400 (nested validation)', async () => {
name: 'foo',
location: {
country: 'XX',
stateProvince: 'Tokyo'
}
} as any
stateProvince: 'Tokyo',
},
} as any,
})
).rejects.toHaveProperty('response.status', 400);

Expand All @@ -358,9 +358,9 @@ test('POST: 400 (nested validation)', async () => {
name: 'foo',
location: {
country: 'JP',
stateProvince: 1234
}
} as any
stateProvince: 1234,
},
} as any,
})
).rejects.toHaveProperty('response.status', 400);
});
Expand All @@ -372,13 +372,13 @@ test('controller dependency injection', async () => {
.inject({
log: () => {
throw new Error();
}
},
})
.inject(() => ({
log: n => {
val = +n * 2;
return Promise.resolve(`${val}`);
}
},
}))(server);

await expect(
Expand All @@ -389,8 +389,8 @@ test('controller dependency injection', async () => {
requiredNumArr: [0],
disable: 'true',
bool: false,
boolArray: []
}
boolArray: [],
},
})
).resolves.toHaveProperty('body.id', `${+id * 2}`);
expect(val).toBe(+id * 2);
Expand Down
4 changes: 2 additions & 2 deletions __test__/unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type Methods = DefineMethods<{
.toBe(`import { defineController } from './$relay';
export default defineController(() => ({
get: () => ({ status: 200, body: 'Hello' })
get: () => ({ status: 200, body: 'Hello' }),
}));
`);

Expand All @@ -37,7 +37,7 @@ export default defineHooks(() => ({
onRequest: (req, reply, done) => {
console.log('Directory level onRequest hook:', req.url);
done();
}
},
}));
`
);
Expand Down
1 change: 0 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const config: Config.InitialOptions = {
testEnvironment: 'node',
globals: { Blob: {} },
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
coveragePathIgnorePatterns: ['\\$api.ts', 'dist']
};

export default config;
Loading

0 comments on commit 4e8aaf6

Please sign in to comment.