Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
990c632
feat(routing): started implemented with new api
plusgut Mar 22, 2024
32b1bf8
chore(eslint): fix lint errors, add list-token
plusgut Mar 22, 2024
8eb54d1
feat(router): implement basic routing handling
plusgut Mar 25, 2024
182ad99
feat(object): implement nested objects
plusgut Apr 2, 2024
35dde3f
chore(route): simplified route creation
plusgut Apr 3, 2024
d30e8c1
chore(container): simplified containerhandler
plusgut Apr 3, 2024
d0c466a
fix(serializer): fix optional for object
plusgut Apr 3, 2024
a04f96e
chore(tokenizer): simplified control flow of tokenize consumption
plusgut Apr 3, 2024
ccce772
fix(serializer): fix default handling for serializer
plusgut Apr 3, 2024
147b04c
chore(tokenizer): normalization of paths
plusgut Apr 4, 2024
7611208
fix(child): implement child namespace handling
plusgut Apr 4, 2024
6bd6469
chore(types): add test for type checking
plusgut Apr 5, 2024
cc06c24
chore(tests): add type assertion tests
plusgut Apr 6, 2024
a38bf0e
fix(tests): fix tests
plusgut Apr 6, 2024
02e72d7
feat(default): implement default handling
plusgut Apr 6, 2024
2d3d253
chore(test): remove unneede check
plusgut Apr 6, 2024
3b9266f
chore(test): add test for urls with nested default needed
plusgut Apr 6, 2024
a490716
feat(string): add string serializer
plusgut Apr 6, 2024
f7a2ad2
feat(string): add default handling to string serializer
plusgut Apr 7, 2024
66926d0
feat(validate): add validation for number
plusgut Apr 7, 2024
4077195
feat(validate): add validation for to-url
plusgut Apr 9, 2024
7ed2c8e
feat(string): add validatio to string handling
plusgut Apr 9, 2024
12eed20
feat(list): add list handling
plusgut Apr 9, 2024
e510ef0
feat(serializer): improve typing of serializers
plusgut Apr 11, 2024
1b107bf
chore(cleanup): remove unneeded code
plusgut Apr 11, 2024
325a99b
fix(list): empty list handling
plusgut Apr 11, 2024
f6a8af3
feat(list): objects are working inside lists
plusgut Apr 11, 2024
467e5b5
feat(boolean): implement boolean serializer
plusgut Apr 11, 2024
a74d23d
chore(cleanup): remove unneeded import
plusgut Apr 11, 2024
a36cb93
feat(date): add date serializer
plusgut Apr 11, 2024
5e82e45
chore(lint): fix linter issue
plusgut Apr 11, 2024
0965fdd
chore(serializer): remove unused validate method in list-serializer
plusgut Apr 11, 2024
a5e1c19
feat(demo): add demo page for router
plusgut Apr 12, 2024
c6d3972
fix(root): fix root-route without parameter handling
plusgut Apr 12, 2024
cc56c5c
chore(lint): add lint-disables
plusgut Apr 12, 2024
6d638f7
chore(enum): add enum handling to router
plusgut Apr 13, 2024
e52b78d
chore(tokenizer): improve tokenizer
plusgut Apr 19, 2024
9a22169
feat(invalid): add invalid parameter handling
plusgut Apr 26, 2024
fd5ad92
chore(refactoring): changed to route-class with global tokenizer state
plusgut May 10, 2024
658a2eb
feat(root): add root-path prefixing
plusgut May 10, 2024
79297aa
chore(string): add empty string handling test
plusgut Jun 2, 2024
9e4757c
feat(default): improve default handling
plusgut Jun 2, 2024
e7afddf
chore(schema)!: renamed serializer to schema
plusgut Jun 2, 2024
c13772d
fix(children): fix child handling
plusgut Mar 25, 2025
e032365
fix(types): default handling
plusgut Mar 25, 2025
845b2b4
fix(types): default handling
plusgut Mar 25, 2025
37e78be
fix(demo): repair html
plusgut Mar 26, 2025
4f046c3
fix(types): improve default handling
plusgut Mar 26, 2025
ebfbfd3
feat(types): add default to list
plusgut Mar 27, 2025
9cf30c1
fix(parser): handling of path-seperator in containers
plusgut Mar 31, 2025
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
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
watch_file package.json
watch_file package-lock.json

use flake
9 changes: 2 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@
],
"env": {
"browser": false,
"es6": true,
"jasmine": true
"es6": true
},
"ignorePatterns": [
"configs/"
],
"ignorePatterns": [],
"rules": {
"no-unused-vars": "off", // necessary for import jsx components/modules
"@typescript-eslint/no-unused-vars": "off", // necessary for import jsx components/modules
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ At compile and runtime the typesafety is guaranteed, for the Route-Components an

```ts
import plusnew, { component } from '@plusnew/core';
import { createRoute, Invalid, NotFound, serializer } from '@plusnew/router';
import { createRoute, Invalid, NotFound, schema } from '@plusnew/router';

const rootRoute = createRoute(
// With the paths the route will be responsible for
'rootRouteName',

// Defines what parameter the route can have
{
oneParameter: [serializer.number()], // This parameter is required and a normal number
sortOrder: [serializer.string('asc'), serializer.string('desc'), serializer.undefined()], // This paramter is optional, when given it has to be the string literal 'asc' | 'desc'
oneParameter: [schema.number()], // This parameter is required and a normal number
sortOrder: [schema.string('asc'), schema.string('desc'), schema.undefined()], // This paramter is optional, when given it has to be the string literal 'asc' | 'desc'
} as const,

// This Component will be shown, when the path is matching the routeName and the parameters
Expand All @@ -35,7 +35,7 @@ const rootRoute = createRoute(
const childRoute = rootRoute.createChildRoute(
'childRouteName',
{
optionalParameter: [serializer.undefined(), serializer.boolean()], // Optional boolean parameter
optionalParameter: [schema.undefined(), schema.boolean()], // Optional boolean parameter
} as const,
component(
'ChildRouteComponent',
Expand Down
40 changes: 40 additions & 0 deletions demo/demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createRootRoute } from "../src";

const rootRoute = createRootRoute({});
const tableRoute = rootRoute.createChildRoute("table", {});

function render(url: string) {
document.body.innerHTML = `<nav>
<ul>
<li>${a(
rootRoute.createPath({ "/": {} }),
rootRoute.map(
url,
({ hasChildRouteActive }) => hasChildRouteActive === false,
) ?? false,
"start",
)}</li>
<li>${a(
tableRoute.createPath({ "/": {}, table: {} }),
tableRoute.map(url, () => true) ?? false,
"table",
)}</li>
</ul>
</nav>
${content(url)}
`;
}

function content(url: string) {
return (
rootRoute.map(url, ({ hasChildRouteActive }) =>
hasChildRouteActive ? null : `<article>Hi there!</article>`,
) ?? "Not found"
);
}

function a(url: string, active: boolean, content: string) {
return `<a class="${active ? "active" : ""}" href="${url}">${content}<a>`;
}

render(window.location.pathname);
78 changes: 78 additions & 0 deletions flake.lock

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

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
npmlock2nixSrc = {
url = "github:nix-community/npmlock2nix";
flake = false;
};
};

outputs = { self, nixpkgs, flake-utils, npmlock2nixSrc }:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system};
npmlock2nix = import npmlock2nixSrc { inherit pkgs; };

in {
devShells.default = npmlock2nix.v2.shell {
nodejs = pkgs.nodejs;
src = ./.;
};

checks.default = npmlock2nix.v2.build {
nodejs = pkgs.nodejs;
src = ./.;
buildCommands = [
"npm exec tsc -- --noEmit"
"CHROME_PATH=${pkgs.chromium}/bin/chromium XDG_CONFIG_HOME=$TMPDIR/chromium-config XDG_CACHE_HOME=$TMPDIR=/chromium-cache npm run test"
];
installPhase = ''
touch $out
'';
};
}
);
}

10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>

<head>
<script type="module" src="./demo/demo.ts"></script>
</head>

<body></body>

</html>
Loading