Skip to content

Commit

Permalink
Merge pull request #153 from frouriojs/develop
Browse files Browse the repository at this point in the history
chore(release): 0.23.1
  • Loading branch information
solufa authored Feb 20, 2021
2 parents 28ee25c + 02d8dbe commit 9885dd0
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 175 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.23.1](https://github.com/frouriojs/frourio/compare/v0.23.0...v0.23.1) (2021-02-20)


### Bug Fixes

* basePath of root endpoint ([d269d76](https://github.com/frouriojs/frourio/commit/d269d76f4038b382baa3ffbd815ac273b8840f33))

## [0.23.0](https://github.com/frouriojs/frourio/compare/v0.22.2...v0.23.0) (2021-02-17)


Expand Down
18 changes: 13 additions & 5 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ import frourio from '../servers/all/$server'
import controller from '../servers/all/api/controller'

const port = 11111
const subPort = 22222
const baseURL = `http://localhost:${port}`
const subBasePath = '/api'
const subBaseURL = `http://localhost:${subPort}${subBasePath}`
const client = api(aspida(undefined, { baseURL }))
const fetchClient = api(aspidaFetch(undefined, { baseURL, throwHttpErrors: true }))
const fetchClient = api(aspidaFetch(undefined, { baseURL: subBaseURL, throwHttpErrors: true }))
let server: FastifyInstance
let subServer: FastifyInstance

beforeEach(cb => {
beforeEach(() => {
server = fastify()
return frourio(server).listen(port, cb)
subServer = fastify()
return Promise.all([
frourio(server).listen(port),
frourio(subServer, { basePath: subBasePath }).listen(subPort)
])
})

afterEach(cb => {
afterEach(() => {
rimraf.sync('packages/frourio/servers/all/.upload')
server.close(cb)
return Promise.all([server.close(), subServer.close()])
})

test('GET: 200', () =>
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frourio",
"version": "0.23.0",
"version": "0.23.1",
"description": "Fast and type-safe full stack framework, for TypeScript",
"author": "Solufa <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -94,27 +94,27 @@
"@types/jest": "^26.0.20",
"@types/node-fetch": "^2.5.8",
"@types/rimraf": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"axios": "^0.21.1",
"class-validator": "^0.13.1",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jest": "^24.1.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^5.0.0",
"fastify": "^3.12.0",
"fastify-multipart": "^4.0.0",
"form-data": "^3.0.0",
"form-data": "^4.0.0",
"jest": "^26.6.3",
"node-fetch": "^2.6.1",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"standard-version": "^9.1.0",
"standard-version": "^9.1.1",
"ts-jest": "^26.5.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.5"
Expand Down
4 changes: 2 additions & 2 deletions servers/all/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
fastify.register(multipart, { attachFieldsToBody: true, limits: { fileSize: 1024 ** 3 }, ...options.multipart })

fastify.get(
`${basePath}/`,
basePath || '/',
{
schema: { response: responseSchema0.get },
onRequest: [...hooks0.onRequest, ctrlHooks0.onRequest],
Expand All @@ -261,7 +261,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
)

fastify.post(
`${basePath}/`,
basePath || '/',
{
onRequest: [...hooks0.onRequest, ctrlHooks0.onRequest],
preParsing: hooks0.preParsing,
Expand Down
2 changes: 1 addition & 1 deletion servers/minimum/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
const controller0 = controllerFn0(fastify)

fastify.get(
`${basePath}/`,
basePath || '/',
{
schema: { response: responseSchema0.get }
},
Expand Down
4 changes: 2 additions & 2 deletions servers/noMulter/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
const controller5 = controllerFn5(fastify)

fastify.get(
`${basePath}/`,
basePath || '/',
{
onRequest: [hooks0.onRequest, ctrlHooks0.onRequest],
preValidation: createValidateHandler(req => [
Expand All @@ -122,7 +122,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
)

fastify.post(
`${basePath}/`,
basePath || '/',
{
onRequest: [hooks0.onRequest, ctrlHooks0.onRequest],
preValidation: createValidateHandler(req => [
Expand Down
4 changes: 2 additions & 2 deletions servers/noTypedParams/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
fastify.register(multipart, { attachFieldsToBody: true, limits: { fileSize: 1024 ** 3 }, ...options.multipart })

fastify.get(
`${basePath}/`,
basePath || '/',
{
onRequest: [hooks0.onRequest, ctrlHooks0.onRequest],
preValidation: createValidateHandler(req => [
Expand All @@ -144,7 +144,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
)

fastify.post(
`${basePath}/`,
basePath || '/',
{
onRequest: [hooks0.onRequest, ctrlHooks0.onRequest],
preValidation: [
Expand Down
4 changes: 2 additions & 2 deletions servers/noValidator/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => {
fastify.register(multipart, { attachFieldsToBody: true, limits: { fileSize: 1024 ** 3 }, ...options.multipart })

fastify.get(
`${basePath}/`,
basePath || '/',
{
onRequest: [hooks0.onRequest, ctrlHooks0.onRequest]
},
asyncMethodToHandler(controller0.get)
)

fastify.post(
`${basePath}/`,
basePath || '/',
{
onRequest: [hooks0.onRequest, ctrlHooks0.onRequest],
preValidation: formatMultipartData([])
Expand Down
10 changes: 7 additions & 3 deletions src/createControllersText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,13 @@ ${validateInfo
hooksTexts.length || resSchemaMethods?.includes(m.name as LowerHttpMethod)
? '\n '
: ''
}\`\${basePath}${`/${dirPath}`
.replace(/\/_/g, '/:')
.replace(/@.+?($|\/)/g, '$1')}\`,${
}${
dirPath
? `\`\${basePath}${`/${dirPath}`
.replace(/\/_/g, '/:')
.replace(/@.+?($|\/)/g, '$1')}\``
: "basePath || '/'"
},${
hooksTexts.length || resSchemaMethods?.includes(m.name as LowerHttpMethod)
? `\n {\n ${
resSchemaMethods?.includes(m.name as LowerHttpMethod)
Expand Down
Loading

0 comments on commit 9885dd0

Please sign in to comment.