Compare commits

...

2 commits

Author SHA1 Message Date
ccbbfd1d3b README: Precise a description of running of a project.
All checks were successful
Build dev / build (push) Successful in 1m0s
2023-11-09 04:43:54 +01:00
5602c22861 Don't import Decimal from internal libraries
This was causing the project build to not work properly.
2023-11-09 04:34:25 +01:00
3 changed files with 21 additions and 9 deletions

View file

@ -6,9 +6,7 @@ Allows for managing order tasks and imported products for a small workshop.
# Running # Running
The project was tested with the nodejs version v18.16.0. It may not work with newer versions of nodejs. The project was tested with the nodejs version v18.17.1. It may not work with versions higher than 18 of nodejs.
Dev dependencies are required. `npm install -D`
Project uses Oracle MySQL as a database store. It uses environment variables for the connection settings. All provided variables below are required. Project uses Oracle MySQL as a database store. It uses environment variables for the connection settings. All provided variables below are required.
@ -16,4 +14,18 @@ Project uses Oracle MySQL as a database store. It uses environment variables for
|----------------------|-------------------| |----------------------|-------------------|
| `DB_URL` | Database url, see [this](https://www.prisma.io/docs/concepts/database-connectors/mysql#connection-url) | | `DB_URL` | Database url, see [this](https://www.prisma.io/docs/concepts/database-connectors/mysql#connection-url) |
After setting variables, you can run the project using `npx nuxi dev` or `npx nuxi preview`. ## From Repository
Dev dependencies are required. `npm install -D`.
After setting variables, you can run the project using `npx nuxi dev`.
You can also setup variables by placing .env file in the root of the repository.
When using nix, you can use `nix-shell` to get prisma engines installed in your environment.
## From Actions
You can download build from [repository actions](https://git.proot.pl/Wroclaw/WorkshopTasker/actions?workflow=build.yml).
You need to extract tar file.
After setting environment variables, you can launch the project using the `node server/index.mjs` command.

View file

@ -1,5 +1,5 @@
import { defineEventHandler, readBody, setResponseStatus } from "h3"; import { defineEventHandler, readBody, setResponseStatus } from "h3";
import { Decimal } from "@prisma/client/runtime/library"; import { Prisma } from "@prisma/client";
import { checkIsWork } from "../../orders.post"; import { checkIsWork } from "../../orders.post";
import { orderExists } from "../[id].get"; import { orderExists } from "../[id].get";
@ -24,7 +24,7 @@ export default defineEventHandler(async (e) => {
notes: body.notes, notes: body.notes,
offerId: BigInt(body.offerId), offerId: BigInt(body.offerId),
orderId: BigInt(body.orderId), orderId: BigInt(body.orderId),
price: new Decimal(body.price), price: new Prisma.Decimal(body.price),
}, },
}); });

View file

@ -1,4 +1,4 @@
import { Decimal } from "@prisma/client/runtime/library"; import { Prisma } from "@prisma/client";
type func = (...args: any[]) => any | Function; type func = (...args: any[]) => any | Function;
@ -8,7 +8,7 @@ export type replaceJsonUnparsableToString<T> =
[K in keyof T]: [K in keyof T]:
T[K] extends null ? null T[K] extends null ? null
: T[K] extends func ? never : T[K] extends func ? never
: T[K] extends Decimal ? `${number}` : T[K] extends Prisma.Decimal ? `${number}`
: T[K] extends Array<infer E> ? Array<replaceJsonUnparsableToString<E>> : T[K] extends Array<infer E> ? Array<replaceJsonUnparsableToString<E>>
: T[K] extends object ? replaceJsonUnparsableToString<T[K]> : T[K] extends object ? replaceJsonUnparsableToString<T[K]>
: T[K] extends bigint ? `${bigint}` : T[K] extends bigint ? `${bigint}`
@ -34,7 +34,7 @@ export function prismaToWeb<T>(ivalue: T): replaceJsonUnparsableToString<T> {
const current = ivalue[i]; const current = ivalue[i];
if (current === null) rvalue[i] = null; if (current === null) rvalue[i] = null;
else if (typeof current === 'function') continue; else if (typeof current === 'function') continue;
else if (current instanceof Decimal) rvalue[i] = current.toString(); else if (current instanceof Prisma.Decimal) rvalue[i] = current.toString();
else if (current instanceof Array) rvalue[i] = arrayPrismaToWeb(current); else if (current instanceof Array) rvalue[i] = arrayPrismaToWeb(current);
else if (typeof current === 'object') rvalue[i] = prismaToWeb(current); else if (typeof current === 'object') rvalue[i] = prismaToWeb(current);
else if (typeof current === 'bigint') rvalue[i] = current.toString(); else if (typeof current === 'bigint') rvalue[i] = current.toString();