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 10, 2023
1 parent a7ff656 commit 495ce5c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 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
40 changes: 39 additions & 1 deletion 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
2 changes: 2 additions & 0 deletions tools/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"eslint": "^8.41.0",
"eslint-plugin-tsdoc": "^0.2.17",
"prettier": "^2.8.8",
"typescript": "^5.0.4"
},
"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 495ce5c

Please sign in to comment.