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

Remove custom server #329

Merged
merged 72 commits into from
Jul 7, 2021
Merged
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ab3cc3a
chore: update yarn
UncleClapton Jun 25, 2021
36d1d49
chore: update yarn once again
UncleClapton Jun 25, 2021
b135a30
chore: change build target to node 14
UncleClapton Jun 25, 2021
0af09a8
refactor: use next-adorable-avatars over koa-adorable-avatars
UncleClapton Jun 25, 2021
72cf781
chore: update and clean deps
UncleClapton Jun 27, 2021
a05ac0f
Add proxies as API routes
UncleClapton Jun 29, 2021
4522d03
refactor: centralize environment config, restructure it for consistency
UncleClapton Jun 29, 2021
df05f92
feat(bind-util): add decorator to bind class methods
UncleClapton Jun 29, 2021
344c3f0
docs(using_jsonApiRoute.md): add start to explainer on middleware
UncleClapton Jun 29, 2021
ee3eb1c
refactor(server): strip out the majority of server components, move w…
UncleClapton Jun 29, 2021
f145398
set server util dir to node env
UncleClapton Jun 29, 2021
b24127a
add koa-compose to do our middleware handling
UncleClapton Jun 29, 2021
f49de53
feat(getEnv-util): add proxy flag
UncleClapton Jun 29, 2021
c432942
docs(using_jsonApiRoute.md): change middleware example
UncleClapton Jun 29, 2021
dae23e7
feat(createResource-util): add generator function for JSONAPI Resourc…
UncleClapton Jun 29, 2021
c8397a6
refactor(trafficController-util): fix jsdoc block
UncleClapton Jun 29, 2021
fb274ee
add generic typing for koa-compose
UncleClapton Jun 29, 2021
9f82df5
feat(jsonApiRoute-util): add middleware for handling jsonAPI responses
UncleClapton Jun 29, 2021
65ec7b6
refactor(version-api-page): use jsonApiRoute to send version data
UncleClapton Jun 29, 2021
840fe5f
feat(ipFilter-util): add IP filter middleware for API routes
UncleClapton Jun 29, 2021
a5182a2
feat(error-util): Add server error collection
UncleClapton Jun 29, 2021
1f7e7eb
refactor(error-util): rework API errors to be closer to the implement…
UncleClapton Jun 29, 2021
3b3c1f8
refactor(bindMethod-decorator): rename from bind so it's intention is…
UncleClapton Jun 30, 2021
0d1a14d
feat(methodRouter-util): add middleware for limiting request methods
UncleClapton Jun 30, 2021
5513d52
feat(donate-api-route): add route for creating donation sessions
UncleClapton Jun 30, 2021
22bf6ef
refactor: abstract API proxy to share defaults
UncleClapton Jun 30, 2021
7b87e99
chore: separate redirects and rewrites so next config is easier to co…
UncleClapton Jun 30, 2021
a5f3e86
refactor: remove index file in src/util/server.
UncleClapton Jun 30, 2021
276bf71
feat(methodrouter-util): send allow header with MethodNotAllowed error.
UncleClapton Jul 1, 2021
3b3e04d
feat(error-util): add not_implemented error
UncleClapton Jul 1, 2021
12a9647
refactor(queue-api-route): send queue data as JSONAPI
UncleClapton Jul 1, 2021
0766b85
feat(jsonApiRoute-util): add flag that allows warning suppression
UncleClapton Jul 1, 2021
e2364c6
feat(jsonApiRoute-util): Add data setter to context so data can be se…
UncleClapton Jul 1, 2021
e204a91
feat(version-api-route): limit method to GET
UncleClapton Jul 1, 2021
c7d2a25
refactor(acceptMethod-util): simplify and rename methodRouter to acc…
UncleClapton Jul 2, 2021
d65c0de
refactor: replace methodRouter with acceptMethod
UncleClapton Jul 2, 2021
b3f60a6
chore: finalize next.config restructure. re-define DefinePlugin vars …
UncleClapton Jul 2, 2021
e67cd7d
chore: remove unused $$BUILD var
UncleClapton Jul 2, 2021
3d2a04e
refactor: use new $$BUILD vars
UncleClapton Jul 2, 2021
3efdf5b
feat(getEnv-util): expose github vars for buildtime DefinePlugin
UncleClapton Jul 2, 2021
32d3327
chore: move config files to .config as this is less confusing.
UncleClapton Jul 4, 2021
59ce304
chore: remove remaining server files
UncleClapton Jul 4, 2021
0f7c51b
fix: disable bodyParser and enable externalResolver option for proxy …
UncleClapton Jul 4, 2021
7d60bd7
chore: update deps, remove old files
UncleClapton Jul 4, 2021
7906f0c
refactor(getEnv-util): restructure getter function, separate out CI e…
UncleClapton Jul 4, 2021
85195e8
refactor: use getEnv where it was previously missed
UncleClapton Jul 4, 2021
2eb0666
style(avatar-routes): add spacing
UncleClapton Jul 4, 2021
ca9f59b
refactor(apiProxy-util): simplify exports
UncleClapton Jul 4, 2021
3d90c9a
fix(frApiProxy-util): remove console.log
UncleClapton Jul 4, 2021
475d468
chore: add missing type for qs
UncleClapton Jul 4, 2021
e014202
chore: fix deps
UncleClapton Jul 4, 2021
1c6f15e
refactor: move helpers directory to util, restructure utilities
UncleClapton Jul 4, 2021
02a5c06
chore: remove unnecessary image domain
UncleClapton Jul 4, 2021
48b3d11
fix: ensure error meta is being defined properly
UncleClapton Jul 4, 2021
41245a7
refactor: remove unnecessary reliance on appUrl
UncleClapton Jul 5, 2021
102b884
fix(user-selectors): use correct default avatar path
UncleClapton Jul 5, 2021
b32aac7
refactor(getCIEnv-config): default git branch to develop
UncleClapton Jul 5, 2021
9392366
refactor(errors-util): default json entires to undefined so they are …
UncleClapton Jul 5, 2021
c2fc11d
chore: update web-util
UncleClapton Jul 5, 2021
26d8ee4
refactor(apiProxy-util): configure logger
UncleClapton Jul 5, 2021
a535842
fix(apiErrorLocalisation-data): add missing internal_server_error data
UncleClapton Jul 5, 2021
64176f2
fix(error-util): ensure getters are error-safe, add message getter, b…
UncleClapton Jul 5, 2021
eca9a61
fix(jsonApiRoute-util): ensure internal errors are properly mapped
UncleClapton Jul 5, 2021
5bf8a8c
fix: ensure build URL is always valid
UncleClapton Jul 5, 2021
834690e
fix(version-page): use standard attribute naming, fix version tag link
UncleClapton Jul 5, 2021
ec5b42f
refactor(paperwork-page): allow error page to handle rescue fetch err…
UncleClapton Jul 5, 2021
49c3342
fix(trafficcontroller-util): use valid header accessing method
UncleClapton Jul 5, 2021
be84f4f
fix(jsonApiRoute-util): correct various errors in ctx reference paths
UncleClapton Jul 5, 2021
e3a2737
refactor(pageRedirect-util): remove redundant setting of res.finished
UncleClapton Jul 5, 2021
768cf18
fix(edit-paperwork-page): remove unused reference to rescue
UncleClapton Jul 5, 2021
88af519
Merge branch 'develop' into refactor/server-slimming
UncleClapton Jul 5, 2021
bca2b6c
chore: move deploy dir to /var/www/fuelrats.dev
UncleClapton Jul 7, 2021
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
Prev Previous commit
Next Next commit
refactor: abstract API proxy to share defaults
UncleClapton committed Jun 30, 2021

Verified

This commit was signed with the committer’s verified signature.
UncleClapton Cameron Welter
commit 22bf6effe9e56f7511d3f292a5a0592dca849125
23 changes: 8 additions & 15 deletions src/pages/api/edsm/[[...slug]].js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import httpProxy from 'next-http-proxy-middleware'

import { getEnv } from '~/util/server'

import apiProxy from '~/util/server/apiProxy'
import getEnv from '~/util/server/getEnv'


const env = getEnv()

export default function edsmApiProxy (res, req) {
return httpProxy(req, res, {
changeOrigin: true,
secure: true,
xfwd: true,
target: env.edsm.url,
pathRewrite: {
'^/api/edsm': '',
},
})
}
export default apiProxy({
target: env.edsm.url,
pathRewrite: {
'^/api/edsm': '',
},
})
27 changes: 11 additions & 16 deletions src/pages/api/fr/[[...slug]].js
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import httpProxy from 'next-http-proxy-middleware'

import { getEnv } from '~/util/server'
import apiProxy from '~/util/server/apiProxy'
import getEnv from '~/util/server/getEnv'



const env = getEnv()




export function frApiProxy (opts = {}) {
return (req, res) => {
return httpProxy(req, res, {
changeOrigin: true,
secure: true,
xfwd: true,
target: env.frapi.url,
...opts,
pathRewrite: {
'^/api/fr': '',
...(opts.pathRewrite ?? {}),
},
})
}
return apiProxy({
target: env.frapi.url,
pathRewrite: {
'^/api/fr': '',
},
...opts,
})
}


24 changes: 8 additions & 16 deletions src/pages/api/wp/[[...slug]].js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import httpProxy from 'next-http-proxy-middleware'

import { getEnv } from '~/util/server'


import apiProxy from '~/util/server/apiProxy'
import getEnv from '~/util/server/getEnv'

const env = getEnv()

export default function wpApiProxy (res, req) {
return httpProxy(req, res, {
changeOrigin: true,
secure: true,
xfwd: true,
target: env.wordpress.url,
pathRewrite: {
'^/api/wp': '/wp-json/wp/v2',
},
})
}
export default apiProxy({
target: env.wordpress.url,
pathRewrite: {
'^/api/wp': '/wp-json/wp/v2',
},
})
16 changes: 16 additions & 0 deletions src/util/server/apiProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import httpProxyMiddleware from 'next-http-proxy-middleware'





export default function apiProxy (...options) {
return (res, req) => {
return httpProxyMiddleware(req, res, {
changeOrigin: true,
secure: true,
xfwd: true,
...options,
})
}
}