dependabot[bot] on npm_and_yarn
dependabot[bot] on npm_and_yarn
build(deps-dev): bump jest from… (compare)
koa-send
?
Hey all, huge fan of koa here.. Have been using Koa + Typescript and it's been so.. "convenient" coming from my normal way of doing things with plain js..
This may be a silly question, but is it OK to read from process.env in files that are not my main server.ts file where I instantiate my new Koa() app and .listen() ?
I'd like to use an ENV value to tell my WebApi the hostname of my OTHER server, however I dont like the idea of hardcoding that into my api source code. And my routes are organized like this: (some files/folders omitted).
--- services (folder)
------ service-name (folder)
--------- upstream-providers (folder)
--------- routes.ts <----- this is the file that needs the OTHER_SERVER_HOSTNAME value
--------- service-name-controller.ts
server.ts <------ this is the main file, and where I NORMALLY touch process.env
response
even through i set it with ctx.cookies.set
for both get and post requestsGET
------------ RESPONSE -----------
{ status: 404,
message: 'Not Found',
header: [Object: null prototype] {},
body: undefined }
------------ REQUEST -----------
{ method: 'GET',
url: '/graphql',
header:
{ host: 'localhost:3000',
connection: 'keep-alive',
'cache-control': 'max-age=0',
'upgrade-insecure-requests': '1',
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36',
accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
cookie:
'name=tandilo; name.sig=nyDQgiinV1lyOZGu9s7xHcE_MYnQxBpAVWmp1MR65i0' } }
###########################
POST
------------ RESPONSE -----------
{ status: 404,
message: 'Not Found',
header: [Object: null prototype] {},
body: undefined }
------------ REQUEST -----------
{ method: 'POST',
url: '/graphql',
header:
{ host: 'localhost:3000',
connection: 'keep-alive',
'content-length': '1468',
accept: '*/*',
origin: 'http://localhost:3000',
'x-apollo-tracing': '1',
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36',
'content-type': 'application/json',
referer: 'http://localhost:3000/graphql',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9' } }
###########################
APOLLO SERVER -------
{ ctx:
{ request: { method: 'POST', url: '/graphql', header: [Object] },
response: { status: 404, message: 'Not Found', header: [Object] },
app: { subdomainOffset: 2, proxy: false, env: 'development' },
originalUrl: '/graphql',
req: '<original node req>',
res: '<original node res>',
socket: '<original node socket>' } }
=====================
I recently developed a framework is Hyron, which helps to save more backend application development time. Serving for large and complex project development, with high expansion needs. Looking forward to receiving suggestions from everyone
https://docs.hyron.org/
module.exports = class {
static requestConfig(){
return {
sayHello : "get"
}
}
sayHello(name){
return "hello world !"+name;
}
}
{
"base_url" : "http://localhost:3000",
"services" : {
"demo" : "./demo.js"
}
}
bash
$ hyron start
result
_
I have a koa newcommer question, which might sound silly :)
does a koa middleware have to call await next()
?
i.e.:
https://gist.github.com/EyalPerry/6fab361cfd6fdf704e7cd5a43c0ede7e