generated from well-known-components/template-server
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
967 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dist/ | ||
*.js | ||
*.d.ts | ||
*.json | ||
src/index.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": "@dcl/eslint-config/sdk", | ||
"parserOptions": { | ||
"project": [ | ||
"tsconfig.json", | ||
"test/tsconfig.json" | ||
] | ||
}, | ||
"rules": { | ||
"prettier/prettier": ["error", { | ||
"printWidth": 120, | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"tabWidth": 2 | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint", | ||
"[typescript]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { HandlerContextWithPath } from "../../types" | ||
import { HandlerContextWithPath } from '../../types' | ||
|
||
// handlers arguments only type what they need, to make unit testing easier | ||
export async function pingHandler(context: Pick<HandlerContextWithPath<"metrics", "/ping">, "url" | "components">) { | ||
export async function pingHandler(context: Pick<HandlerContextWithPath<'metrics', '/ping'>, 'url' | 'components'>) { | ||
const { | ||
url, | ||
components: { metrics }, | ||
components: { metrics } | ||
} = context | ||
|
||
metrics.increment("test_ping_counter", { | ||
pathname: url.pathname, | ||
metrics.increment('test_ping_counter', { | ||
pathname: url.pathname | ||
}) | ||
|
||
return { | ||
body: url.pathname, | ||
body: url.pathname | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { Router } from "@well-known-components/http-server" | ||
import { GlobalContext } from "../types" | ||
import { pingHandler } from "./handlers/ping-handler" | ||
import { Router } from '@well-known-components/http-server' | ||
import { GlobalContext } from '../types' | ||
import { pingHandler } from './handlers/ping-handler' | ||
|
||
// We return the entire router because it will be easier to test than a whole server | ||
export async function setupRouter(globalContext: GlobalContext): Promise<Router<GlobalContext>> { | ||
export async function setupRouter(_: GlobalContext): Promise<Router<GlobalContext>> { | ||
const router = new Router<GlobalContext>() | ||
|
||
router.get("/ping", pingHandler) | ||
router.get('/ping', pingHandler) | ||
|
||
return router | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Lifecycle } from "@well-known-components/interfaces" | ||
import { initComponents } from "./components" | ||
import { main } from "./service" | ||
import { Lifecycle } from '@well-known-components/interfaces' | ||
import { initComponents } from './components' | ||
import { main } from './service' | ||
|
||
// This file is the program entry point, it only calls the Lifecycle function | ||
Lifecycle.run({ main, initComponents }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.