Skip to content

Commit

Permalink
✨ Add build process for @workspace/common
Browse files Browse the repository at this point in the history
  • Loading branch information
cermakjiri committed Nov 7, 2024
1 parent 506b9a3 commit 401f655
Show file tree
Hide file tree
Showing 210 changed files with 108 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<

await updatePasskey(passkey.id, {
credentialCounter: result.authenticationInfo.newCounter,
// @ts-expect-error
lastUsedAt: FieldValue.serverTimestamp(),
});

Expand Down
10 changes: 4 additions & 6 deletions examples/webauthn-default/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@
"extends": "@tooling/typescript/nextjs",
"compilerOptions": {
"baseUrl": ".",
"jsx": "preserve",
"paths": {
"~*": [
"./src/*",
],
"@workspace/common/*": [
"../../common/*",
],
"~public/*": [
"./public/*"
],
"@workspace/common/*": [
"../../packages/common/dist/*"
]
}
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.mts"
"**/*.tsx"
]
}
1 change: 0 additions & 1 deletion packages/common/client/env/index.ts

This file was deleted.

7 changes: 5 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lint": "eslint-lint --config=eslint.config.mjs ./**/*.{ts,tsx}",
"lint:fix": "yarn lint --fix",
"format": "prettier-format",
"cir-dep": "check-cir-deps ."
"cir-dep": "check-cir-deps .",
"build": "tsc && tsc-alias"
},
"dependencies": {
"@ackee/antonio-core": "5.0.0",
Expand Down Expand Up @@ -38,6 +39,7 @@
"react-intl": "6.8.7",
"react-toastify": "10.0.6",
"reset.css": "2.0.2",
"typescript": "5.6.3",
"zod": "3.23.8"
},
"devDependencies": {
Expand All @@ -46,6 +48,7 @@
"@tooling/prettier": "workspace:*",
"@tooling/typescript": "workspace:*",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1"
"@types/react-dom": "18.3.1",
"tsc-alias": "1.8.10"
}
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/common/src/client/env/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { env } from './env.mjs';
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ export type Pathname = string;
export type RenderRoute = () => ReactElement;
export type UnknownRoutes = Readonly<Record<Pathname, RenderRoute>>;

export type ExampleRouterContextValue<Routes extends UnknownRoutes> = {
routes: Routes;
currentRoute: keyof Routes;
redirect: (route: keyof Routes) => void;
};

export interface ExampleRouterProps<Routes extends UnknownRoutes> {
children: ReactNode;
initialRoute: keyof Routes;
routes: Routes;
}

export function createExampleRouter<Routes extends UnknownRoutes>() {
type Route = keyof Routes;

type ExampleRouterContextValue = {
routes: Routes;
currentRoute: Route;
redirect: (route: Route) => void;
};

const ExampleRouterContext = createContext<ExampleRouterContextValue | undefined>(undefined);

interface ExampleRouterProps {
children: ReactNode;
initialRoute: Route;
routes: Routes;
}
const ExampleRouterContext = createContext<ExampleRouterContextValue<Routes> | undefined>(undefined);

const ExampleRouter = ({ children, initialRoute, routes }: ExampleRouterProps) => {
const ExampleRouter = ({ children, initialRoute, routes }: ExampleRouterProps<Routes>) => {
const [currentRoute, setCurrentRoute] = useState<keyof Routes>(initialRoute);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { collection, getDocs, limit, orderBy, query, where } from 'firebase/firestore';

import { db } from '@workspace/common/client/firebase/config';
import { collections } from '@workspace/common/server/constants/collections';
import type { Passkey } from '@workspace/common/types';
import { db } from '~client/firebase/config';
import { collections } from '~server/constants/collections';
import type { Passkey } from '~types';

export const fetchUserPasskeys = async (userId: Passkey['userId']) => {
const passkeysCollection = collection(db(), collections.Passkeys);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { UseMutationResult } from '@tanstack/react-query';

import type { Passkey as TPasskey } from '~client/types';
import { Button, Card, CardContent } from '~client/ui-kit';
import { Delete } from '~client/ui-kit/icons';
import type { Passkey as TPasskey } from '~types';

import { BackedUp } from './BackedUp';
import { Caption } from './Caption';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
// @ts-ignore
import { useCallback, type ReactNode } from 'react';
import { toast as toasts, type ToastOptions } from 'react-toastify';

import { Alert, alertClasses, Words } from '~client/ui-kit';

export type * from 'react-toastify';

export type SnackType = 'success' | 'error';

export type UseSnack = (
type: SnackType,
message: ReactNode,
options?: ToastOptions,
) => Readonly<(typeof toasts)[SnackType]>;

export function useSnack() {
return useCallback((type: 'success' | 'error', message: ReactNode, options?: ToastOptions) => {
return useCallback<UseSnack>((type, message, options) => {
const toast = toasts[type];

const toastId = toast(
Expand Down Expand Up @@ -32,6 +43,6 @@ export function useSnack() {
},
);

return { ...toasts, toastId };
return { ...toasts, toastId } as const;
}, []);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { logger } from '@workspace/common/logger';

import { logger } from '~logger';
import { auth } from '~server/config/firebase';

export async function parseAndVerifyIdToken(authorizationHeader: string | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@simplewebauthn/server/helpers';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';

import { logger } from '@workspace/common/logger';
import { logger } from '~logger';

/**
* An example of how to all data parse the registration response.
Expand Down
File renamed without changes.
19 changes: 14 additions & 5 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
{
"extends": "@tooling/typescript/nextjs",
"compilerOptions": {
"baseUrl": ".",
"baseUrl": "./src",
"paths": {
"~*": [
"./*"
],
}
},
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"declarationDir": "dist",
"noEmit": false,
},
"include": [
"**/*.ts",
"**/*.tsx",
]
"./src/**/*.ts",
"./src/**/*.tsx",
],
"exclude": [
"dist",
"node_modules"
],
}
4 changes: 0 additions & 4 deletions tooling/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"bin": {
"eslint-lint": "./bin/cli.js"
},
"files": [
"bin",
"config"
],
"exports": {
"./config": "./config/next.js"
},
Expand Down
6 changes: 1 addition & 5 deletions tooling/typescript/nextjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
{
"name": "next"
}
],
"paths": {
"~*": ["./src/*"],
"~public/*": ["./public/*"]
}
]
},
"include": ["src", "next-env.d.ts"]
}
50 changes: 49 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3739,6 +3739,8 @@ __metadata:
react-intl: "npm:6.8.7"
react-toastify: "npm:10.0.6"
reset.css: "npm:2.0.2"
tsc-alias: "npm:1.8.10"
typescript: "npm:5.6.3"
zod: "npm:3.23.8"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -4437,6 +4439,13 @@ __metadata:
languageName: node
linkType: hard

"commander@npm:^9.0.0":
version: 9.5.0
resolution: "commander@npm:9.5.0"
checksum: 10c0/5f7784fbda2aaec39e89eb46f06a999e00224b3763dc65976e05929ec486e174fe9aac2655f03ba6a5e83875bd173be5283dc19309b7c65954701c02025b3c1d
languageName: node
linkType: hard

"commondir@npm:^1.0.1":
version: 1.0.1
resolution: "commondir@npm:1.0.1"
Expand Down Expand Up @@ -5927,7 +5936,7 @@ __metadata:
languageName: node
linkType: hard

"globby@npm:^11.1.0":
"globby@npm:^11.0.4, globby@npm:^11.1.0":
version: 11.1.0
resolution: "globby@npm:11.1.0"
dependencies:
Expand Down Expand Up @@ -7359,6 +7368,13 @@ __metadata:
languageName: node
linkType: hard

"mylas@npm:^2.1.9":
version: 2.1.13
resolution: "mylas@npm:2.1.13"
checksum: 10c0/093dfaf88f444d9da956c68a61ddcfe05ab9411c0024b0c7f4d721639ba7d311ea8f9c052ce617344e67d40982f67614cd634b525b923048bf9a191234968c9c
languageName: node
linkType: hard

"nanoid@npm:^3.3.6, nanoid@npm:^3.3.7":
version: 3.3.7
resolution: "nanoid@npm:3.3.7"
Expand Down Expand Up @@ -7859,6 +7875,15 @@ __metadata:
languageName: node
linkType: hard

"plimit-lit@npm:^1.2.6":
version: 1.6.1
resolution: "plimit-lit@npm:1.6.1"
dependencies:
queue-lit: "npm:^1.5.1"
checksum: 10c0/af5d351bb55afe1eaa84b27c2b329699e150e4cf70464f3d474f5eabe9bdb9f48ed378ada1498d3b893f68ee7da2423ba6d9a4d88b1429d3b0aea22afcf5292b
languageName: node
linkType: hard

"pluralize@npm:^8.0.0":
version: 8.0.0
resolution: "pluralize@npm:8.0.0"
Expand Down Expand Up @@ -8126,6 +8151,13 @@ __metadata:
languageName: node
linkType: hard

"queue-lit@npm:^1.5.1":
version: 1.5.2
resolution: "queue-lit@npm:1.5.2"
checksum: 10c0/8aa838b2c939aeaa6cd272b5b6b172379a3fa1d9193b2a3e687643c68c0efee3cd3493af4f1f8a11ff79b8207e4d00cc5d0b072f6e4bbeaaa27ee01f567ec4ac
languageName: node
linkType: hard

"queue-microtask@npm:^1.2.2":
version: 1.2.3
resolution: "queue-microtask@npm:1.2.3"
Expand Down Expand Up @@ -9199,6 +9231,22 @@ __metadata:
languageName: node
linkType: hard

"tsc-alias@npm:1.8.10":
version: 1.8.10
resolution: "tsc-alias@npm:1.8.10"
dependencies:
chokidar: "npm:^3.5.3"
commander: "npm:^9.0.0"
globby: "npm:^11.0.4"
mylas: "npm:^2.1.9"
normalize-path: "npm:^3.0.0"
plimit-lit: "npm:^1.2.6"
bin:
tsc-alias: dist/bin/index.js
checksum: 10c0/6f319d37b35d2f660c09c4a5413305c78943dd09bdaf395f4c1da69e19ad15b4d149db28d9251acd8bb52e755af55895018b2fe55f1511774da2e9e30a5c826a
languageName: node
linkType: hard

"tsconfig-paths@npm:^3.15.0":
version: 3.15.0
resolution: "tsconfig-paths@npm:3.15.0"
Expand Down

0 comments on commit 401f655

Please sign in to comment.