Skip to content

Commit

Permalink
Setting up docs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpangalos committed Jun 12, 2023
1 parent 97ad605 commit a8314a6
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml -diff
10 changes: 6 additions & 4 deletions packages/little-router/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export type PluginContext<
readonly params: Record<string, string>;
/**
* This is only used for adding typing hints to requests
* @private */
*
* @private
*/
readonly __hint?: HINT;
};
/**
* _hint is for giving hints to the consumer making the request
* regarding the request init and any possible search params
* */
* _hint is for giving hints to the consumer making the request regarding the
* request init and any possible search params
*/
export type Plugin<REST_ARGS extends unknown[] = unknown[]> = (
{ request, url, params }: PluginContext<any>,
...rest: REST_ARGS
Expand Down
24 changes: 24 additions & 0 deletions packages/little-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@ import { HasOverlap } from "./overlap.js";
import { Plugin, PluginContext } from "./plugin.js";
import { FetchDefinition, Queries } from "./fetch.js";

/**
* Returns an instance of RouteBuilder that you can use to build your routing
* structure.
*
* @typeParam REST_ARGS - Used to type Env and ExecutionContext from cloudflare
* workers. More info in [cloudflare workers docs]( https://developers.cloudflare.com/workers/platform/environment-variables/).
*
* The returned RouteBuilder can be build upon by using the method function,
* with names corresponding to http request methods.
*
* {@link Method | Availible Methods}
*
* @example
* ```ts
* type Env = {
* MY_ENV_VAR: string;
* MY_SECRET: string;
* myKVNamespace: KVNamespace;
* };
* const router = Router<Env, ExecutionContext>
* ```
*
* More on cloudflare worker types in [their documentation](https://github.com/cloudflare/workerd/tree/main/npm/workers-types#using-bindings).
*/
export const Router = <REST_ARGS extends unknown[] = []>(): RouteBuilder<
REST_ARGS,
never
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tools/config/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc"],
root: true,
rules: {
"tsdoc/syntax": "warn",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/no-explicit-any": "off",
},
Expand Down
7 changes: 3 additions & 4 deletions tools/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"private": true,
"version": "0.0.10",
"description": "",
"files": [
"tsconfig.json",
".eslintrc.cjs"
],
"files": ["tsconfig.json", ".eslintrc.cjs"],
"scripts": {},
"keywords": [],
"author": "",
Expand All @@ -15,13 +12,15 @@
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"eslint-plugin-tsdoc": "^0.2.17",
"prettier": "^2.8.8",
"typescript": "^5.1.3"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"eslint": "^8.39.0",
"eslint-plugin-tsdoc": "^0.2.17",
"prettier": "^2.8.8",
"typescript": "^5.0.4"
}
Expand Down

0 comments on commit a8314a6

Please sign in to comment.