Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFR: Big Falcon Refactoring #609

Merged
merged 98 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
bef8222
Move pricingSheet and calculate to order module (delivery and payment)
pozylon Nov 27, 2024
a4eceeb
Fix delivery and payment plugins any context
pozylon Nov 27, 2024
bbbca65
Allow to mix in unchained api to director types
pozylon Nov 27, 2024
0f4f636
Refactor pricing
pozylon Nov 27, 2024
b55ce10
Pass currency correctly
pozylon Nov 27, 2024
98d9b69
Refactor findSupported and move it to services
pozylon Nov 27, 2024
9d636fc
Refactor findSupported and move it to services (payment)
pozylon Nov 27, 2024
ee593ef
Remove unchained api
pozylon Nov 27, 2024
efa0e0b
when is a data
pozylon Nov 27, 2024
b4243cf
Fix token expiry
pozylon Nov 27, 2024
a037959
Refactor payment and delivery to be mostly core-free
pozylon Nov 28, 2024
fe63506
Simplify
pozylon Nov 28, 2024
f35a851
Move tokenizeItem und tokenMetadata
pozylon Nov 28, 2024
7a75c50
Move estimatedDispatch
pozylon Nov 28, 2024
24b7bbe
Fix estimatedStock
pozylon Nov 28, 2024
beee4c8
Fix director types
pozylon Nov 28, 2024
db1522b
Move stuff
pozylon Nov 28, 2024
76e007e
Fix currency tangling
pozylon Nov 29, 2024
f954efc
Start to simplify enrollments
pozylon Dec 3, 2024
692b879
Fix enrollments module typing
pozylon Dec 4, 2024
a243b65
Fix filters module typing
pozylon Dec 4, 2024
71685bf
Filters
pozylon Dec 4, 2024
2828380
Filter services
pozylon Dec 4, 2024
975f6a9
Fix product types
pozylon Dec 4, 2024
517f339
It get’s freezing cold down the rabbit hole 🤣
pozylon Dec 6, 2024
0223ee3
Fix parts of cart mutations to not depend on context
pozylon Dec 6, 2024
6153e02
Move away Director reference in core modules
pozylon Dec 6, 2024
2980733
Remove pricingSheet fn’s because of ambiguity
pozylon Dec 6, 2024
6de32e8
Remove pricingSheet fn’s because of ambiguity
pozylon Dec 6, 2024
70a9748
Move discounted
pozylon Dec 6, 2024
8e6c25b
Move updateScheduling to services
pozylon Dec 6, 2024
3d9a79c
Milestone: completely decoupled core usage in core modules, next up: …
pozylon Dec 6, 2024
1343873
Move DeliveryDirector to core
pozylon Dec 6, 2024
289fc35
Move EnrollmenDirector to core
pozylon Dec 6, 2024
ed24066
Move ProductDirector and FilterDirector to core
pozylon Dec 6, 2024
1d4c469
Adjust types to core
pozylon Dec 6, 2024
8b88f8c
Move order adapters to core
pozylon Dec 6, 2024
c4eef9a
Move warehousing director to core
pozylon Dec 6, 2024
8f4fd06
Fix base pricing sheet dependency of OrderDirector
pozylon Dec 6, 2024
d856b1e
Move discount handling
pozylon Dec 9, 2024
1536bdb
Move initialConfiguration to callee
pozylon Dec 9, 2024
1ede802
Move price simulation to api
pozylon Dec 9, 2024
3483779
Move enrollment processing to services
pozylon Dec 9, 2024
238cc29
Fix some checkout problems
pozylon Dec 9, 2024
425901d
Fix discounts
pozylon Dec 9, 2024
f98d5f9
Default quantity to 1 if not set
pozylon Dec 9, 2024
216b8f2
Fix quantity default
pozylon Dec 9, 2024
32341d0
Fix orderId
pozylon Dec 9, 2024
773642a
Update eslint
pozylon Dec 9, 2024
5931999
Use rust bcrypt instead of bcryptjs (50% faster)
pozylon Dec 9, 2024
51e64d1
Fix filter
pozylon Dec 9, 2024
3f3c559
Move worker director
pozylon Dec 10, 2024
9a7664d
Move worker management
pozylon Dec 10, 2024
80f1460
Fix recursion
pozylon Dec 10, 2024
94efcef
Move messaging management
pozylon Dec 10, 2024
a96dda7
Remove quotations entanglement
pozylon Dec 10, 2024
d66c33c
Adjust enrollment typing
pozylon Dec 10, 2024
eb15929
Inline product search and assortment search indirection
pozylon Dec 11, 2024
f08d1e4
Move internal filter fn to core and api
pozylon Dec 11, 2024
223b6e9
Complete unchainedAPI typing
pozylon Dec 11, 2024
0645f82
Update deps
pozylon Dec 11, 2024
fff9367
Fix optional/dev dependencies
pozylon Dec 11, 2024
0dbacff
Get rid of winston dependencies
pozylon Dec 11, 2024
95f8cf5
Move fileUrl
pozylon Dec 11, 2024
6fa5c47
Implement erc metadata for fastify
pozylon Dec 12, 2024
5d7fd57
Remove passport-strategy and enable erc metadata and bulk import hand…
pozylon Dec 12, 2024
aec227b
Enforce WebCrypto to hash
pozylon Dec 12, 2024
695cd7f
Fix chainTokenId
pozylon Dec 12, 2024
64bbc20
Fix bulk importer
pozylon Dec 12, 2024
2d1afe5
Type order templates
pozylon Dec 12, 2024
6d9309d
Lockfile
pozylon Dec 13, 2024
c49f7d6
Fix signature generation for datatrans
pozylon Dec 13, 2024
03b2abd
Fix file signatures and tests
pozylon Dec 13, 2024
2698626
Merge branch 'master' into hardcore-refactor
pozylon Dec 13, 2024
1e39e18
WIP: Add private flag option on file upload
Mikearaya Nov 25, 2024
f0fade8
Lock Media.url
Mikearaya Nov 26, 2024
bb6e4b0
Update media upload endpoint to accept private flag
Mikearaya Nov 26, 2024
66f2c97
Extend file adapter with url sign util and add signature and expirati…
Mikearaya Nov 26, 2024
ec82e04
Merge branch 'master' into hardcore-refactor
pozylon Dec 13, 2024
a3ec586
Make compatible with Bun
pozylon Dec 13, 2024
2d1519d
Add requested changes
Mikearaya Dec 14, 2024
99d5293
Move url signing responsibility to adapter
Mikearaya Dec 14, 2024
46ad40e
Lock private file download option based on user and adapter
Mikearaya Dec 15, 2024
7cd5bfc
Move url signer adapter check into file adapter base class
Mikearaya Dec 16, 2024
d8ce9a7
Move privateFileSharingMaxAge access into file adapter
Mikearaya Dec 16, 2024
384d3c1
Lock avatar upload
Mikearaya Dec 16, 2024
02e094d
Add event-bridge plugin
pozylon Dec 17, 2024
7e29b82
Update changelog
pozylon Dec 17, 2024
a1e18a7
Add media permissions integration tests
Mikearaya Dec 17, 2024
41c0675
new service architecture (wip)
pozylon Dec 17, 2024
a1be970
Add media download/access tests
Mikearaya Dec 17, 2024
6a4f18a
Add private tag in meta
Mikearaya Dec 17, 2024
1f908db
Move file access check into adapter
Mikearaya Dec 17, 2024
9517558
new service architecture (wip)
pozylon Dec 17, 2024
875bfb1
Move signing url call into getUrl
Mikearaya Dec 17, 2024
bb79ddc
Fix regression
pozylon Dec 17, 2024
15d26e1
Update changelog and packages
pozylon Dec 17, 2024
eaa7069
Merge branch 'restrict-file-access' into hardcore-refactor
pozylon Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 19 additions & 18 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
# Unchained Engine vNEXT
## Minor
- API: Extend `Query.users` to accept additional filter options `emailVerified` & `lastLogin`

## Breaking
- Change argument format of `Query.workStatistics`, `Query.eventStatistics` & `Query.orderStatistics` from previous
- The order module function `initProviders` has been moved to order services renamed as `initCartProviders`
- The order module function `updateCalculation` has been moved to order services
- The order module function `invalidateProviders` has been removed, the caller now uses the new `findCartsToInvalidate` to get the list of carts and then calls the new updateCalculation service

# Unchained Engine v3.0

## Removing the auth fat of unchained
We experienced feature creep in the authentication part of Unchained and suddenly woke up to homemade implementations of Two-Factor Auth via TOTP, WebAuthn, oAuth, Impersonator features etc. Many solutions like Zitadel, Keycloak, Auth0 etc. solve that just perfect and keep up with the ever increasing complexity of auth mechanisms. At the same time, core-accountsjs depends on a package called accountsjs which is unmaintained and uses a conflicting old mongodb driver.

That's why we have decided to remove various auth features that are better solved through Identity Management systems and migrate to passport.js which is also ESM now. That opens the door to complex login methods like OpenID Connect through the community of passport.js,
That's why we have decided to remove various auth features that are better solved through Identity Management systems and migrate to passport.js which is also ESM now. That opens the door to complex login methods like OpenID Connect through the community of passport.js.

We will keep supporting the following auth-strategies out of the box that we consider widely known web standards:
- E-Mail/Username & Password
- WebAuthn (Passkeys)
- Access Tokens

## Major
- Drop support for Node.js <22.x
- `from` & `to` to `dateRange` of type `DateFilterInput` for consistency.
- Removed sugar connectPlatformToExpress4 to save dependencies when running in no-express env, use `import { connect } from '@unchainedshop/api/express/index.js'` now.
- Removed `core-accounts`, migrated some settings partially to user settings (removed sendVerificationEmailAfterSignup, introduced new validation functions)
- LoginMethodResponse has a new breaking GraphQL type
- Remove logoutAllSessions and remove support for loging out a specific session
- Introduce default password rules (min. 8 chars)
- Drop 2FA support (if you want this, use a passport plugin)
- Drop oAuth support (if you want this, use a passport plugin)
- Auth: Removed `core-accounts`, migrated some settings partially to user settings (removed sendVerificationEmailAfterSignup, introduced new validation functions)
- Auth: Remove logoutAllSessions and remove support for loging out a specific session
- Auth: Introduce default password rules (min. 8 chars)
- Auth: Drop 2FA support (if you need special authentication strategies, use a passport or fastify plugin)
- Auth: Drop oAuth support (if you need special authentication strategies, use a passport or fastify plugin)
- Core: The order module function `initProviders` has been moved to order services renamed as `initCartProviders`
- Core: The order module function `updateCalculation` has been moved to order services
- Core: The order module function `invalidateProviders` has been removed, the caller now uses the new `findCartsToInvalidate` to get the list of carts and then calls the new updateCalculation service
- API: Add built-in Fastify support
- API: Add built-in Yoga support (we are going to deprecate Apollo Server starting from 4.x)
- API: `LoginMethodResponse` has a new breaking GraphQL type
- Platform: Removed sugar connectPlatformToExpress4 to save dependencies when running in no-express env, use `import { connect } from '@unchainedshop/api/express/index.js'` now.

## Minor
- API: Extend `Mutation.confirmOrder` and `Mutation.rejectOrder` with a comment field. Allows to provide arbitrary data like a rejection reason that you can use in messaging.
- API: Change argument format of `Query.workStatistics`, `Query.eventStatistics` & `Query.orderStatistics` from previous
- API: Extend `Query.users` to accept additional filter options `emailVerified` & `lastLogin`
- Plugins: Add AWS Event Bridge Plugin for Serverless Mode


# Unchained Engine v2.14

Expand Down
1 change: 0 additions & 1 deletion docs/docs/advanced/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Below are events tracked under each module under the box:
| ORDER_SIGN_PAYMENT | Order payment provider is signed | `{ orderPayment: {}, transactionContext: {} }` |
| ORDER_REMOVE | Order is deleted | `{ orderId: string }` |
| ORDER_ADD_PRODUCT | Product is added to an order | `{ orderPosition : {} }` |
| ORDER_ADD_DISCOUNT | Discount is added to an order | `{ discount: {} }` |
| ORDER_CONFIRMED | Order is confirmed | `{ order: {} }` |
| ORDER_FULLFILLED | All requested items are fullfiled for an order | `{ order: {} }` |
| ORDER_REJECTED | Order is rejected | `{ order: {} }` |
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/advanced/messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const errorReported: TemplateResolver = async (


```typescript
import { MessagingDirector } from "@unchainedshop/core-messaging";
import { MessagingDirector } from "@unchainedshop/core";

MessagingDirector.registerTemplate("ERROR_REPORT", errorReported);
```
Expand Down
4 changes: 0 additions & 4 deletions docs/docs/advanced/write-plugins/delivery-pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export const ShopDeliveryFreePrice: IDeliveryPricingAdapter = {
const { currency } = context;
const resultSheet = DeliveryPricingSheet({ currency });
return {
getCalculation: () => calculation,
getContext: () => context,
calculate: async () => {
resultSheet.addFee({
amount: 50,
Expand All @@ -61,6 +59,4 @@ export const ShopDeliveryFreePrice: IDeliveryPricingAdapter = {
```

- **isActivatedFor: [DeliveryPricingAdapterContext](https://docs.unchained.shop/types/interfaces/delivery_pricing.DeliveryPricingAdapterContext.html)**: defines to which delivery adapters this delivery price adapter calculations should take place.
- **getCalculation: [Calculation[]](https://docs.unchained.shop/types/interfaces/pricing.PricingSheetParams.html#calculation)**: returns all the fees that will are included for calculation through the adapter.
- **getContext: [DeliveryPricingAdapterContext](https://docs.unchained.shop/types/interfaces/delivery_pricing.DeliveryPricingAdapterContext.html)**: returns the pricing adapter context
- **calculate: [Calculation[]](https://docs.unchained.shop/types/interfaces/pricing.PricingSheetParams.html#calculation)**: calculated the delivery price based on the logic provided and returns the calculation breakdown (result sheet)
3 changes: 0 additions & 3 deletions docs/docs/advanced/write-plugins/order-pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const ShopOrderPricingAdapter: IOrderPricingAdapter = {
);
return resultRaw;
},
getContext: () => params.context,
resultSheet: () => resultSheet,
getCalculation: () => calculation,
};
},
};
Expand All @@ -54,7 +52,6 @@ export const ShopOrderPricingAdapter: IOrderPricingAdapter = {

- **isActiveFor(context: [OrderPricingAdapterContext](https://docs.unchained.shop/types/interfaces/orders_pricing.OrderPricingAdapterContext.html))**: Used to activate or de-active a particular order price plugin based on the current context of the order or any other business rule.
- **calculate**: is where the actual calculation of the order price is done based on the calculation items defined for the adapter.
- **getContext**: returns the current order payment price plugin context.
- **resultSheet**: return the price sheet items that are applied on the price adapter.


Expand Down
15 changes: 6 additions & 9 deletions docs/docs/advanced/write-plugins/payment-pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
PaymentPricingAdapterContext,
IPaymentPricingSheet,
PaymentPricingCalculation,
} from '@unchainedshop/core-payment';
} from '@unchainedshop/core';

const TRANSACTION_FEE = 29;

Expand Down Expand Up @@ -61,11 +61,11 @@ export const ShopCommission: IPaymentPricingAdapter = {
});

const totalValueOfGoods = orderPositions.reduce((current, orderPosition) => {
const pricing = context.modules.orders.positions.pricingSheet(
orderPosition,
context.order.currency,
params.context,
);
const pricing = ProductPricingSheet({
calculation: orderPosition.calculation,
currency: context.order.currency,
quantity: orderPosition.quantity,
});
const items = pricing.gross();
return current + items;
}, 0);
Expand All @@ -91,9 +91,7 @@ export const ShopCommission: IPaymentPricingAdapter = {
);
return resultRaw;
},
getContext: (): PaymentPricingAdapterContext => params.context,
resultSheet: () => resultSheet,
getCalculation: (): PaymentPricingCalculation[] => calculation,
};
},
};
Expand All @@ -102,7 +100,6 @@ export const ShopCommission: IPaymentPricingAdapter = {

- **isActiveFor(context: [PaymentPricingAdapterContext](https://docs.unchained.shop/types/interfaces/payments_pricing.PaymentPricingAdapterContext.html))**: Used to activate or de-active a particular payment price plugin based on the current context of the order or any other business rule.
- **calculate**: is where the actual calculation of the payment price is done based on the calculation items defined for the adapter.
- **getContext**: returns the current payment price plugin context.
- **resultSheet**: return the price sheet items that are applied on the price adapter.

## Registering payment pricing adapters
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/advanced/write-plugins/payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
PaymentError,
} from '@unchainedshop/core-payment';

const ShopPayment: IPaymentAdapter<UnchainedCore> = {
const ShopPayment: IPaymentAdapter = {
key: 'ch.Shop.payment',
label: 'Shop Payment',
version: '1.0.0',
Expand Down
6 changes: 0 additions & 6 deletions docs/docs/api/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,6 @@ sidebar_position: 6
<td>ORDER_REMOVE_DISCOUNT</td>
<td>

</td>
</tr>
<tr>
<td>ORDER_ADD_DISCOUNT</td>
<td>

</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/plugins/push-notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ the only difference is push notification worker expects a input type that is sli
Here is an example template resolver that will trigger a PUSH notification to a user if they are subscribed

```js
import { MessagingDirector } from "@unchainedshop/core-messaging";
import { MessagingDirector } from "@unchainedshop/core";
export const helloThere: TemplateResolver = async (
{ },
context: UnchainedCore
Expand Down
File renamed without changes.
26 changes: 11 additions & 15 deletions examples/kitchensink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
"lint": "prettier -w .",
"clean": "tsc -b --clean",
"build": "tsc -b",
"start": "node lib/boot.js",
"dev:run": "node --experimental-fetch --no-warnings --loader ts-node/esm boot.ts",
"start": "node --import ./load_env.js lib/boot.js",
"dev:run": "node --import ./load_env.js --no-warnings --loader ts-node/esm src/boot.ts",
"dev": "nodemon --delay 2500ms --watch '../../packages' --watch '.' -i lib -e js,mjs,json,ts --exec \"npm run dev:run\""
},
"dependencies": {
"@graphql-yoga/plugin-response-cache": "^3.12.3",
"@graphql-yoga/plugin-response-cache": "^3.12.6",
"@paypal/checkout-server-sdk": "^1.0.3",
"@unchainedshop/api": "^3.0.0-alpha4",
"@unchainedshop/core-delivery": "^3.0.0-alpha4",
Expand All @@ -43,32 +43,28 @@
"@unchainedshop/plugins": "^3.0.0-alpha4",
"@unchainedshop/ticketing": "^3.0.0-alpha4",
"bip32": "^4.0.0",
"bitcoinjs-lib": "^6.1.6",
"cookie-parser": "^1.4.7",
"bitcoinjs-lib": "^6.1.7",
"dotenv-extended": "^2.9.0",
"ethers": "^6.13.4",
"event-iterator": "^2.0.0",
"express": "^4.21.1",
"express": "^4.21.2",
"express-session": "^1.18.1",
"graphql": "^16.9.0",
"JSONStream": "^1.3.5",
"graphql": "^16.10.0",
"nodemailer": "^6.9.16",
"open": "^10.1.0",
"passport": "^0.7.0",
"passport-strategy": "^1.0.0",
"postfinancecheckout": "^4.5.0",
"serve-static": "^1.15.0",
"stripe": "^17.4.0",
"tiny-secp256k1": "^2.2.3",
"twilio": "^5.3.6",
"twilio": "^5.4.0",
"web-push": "^3.6.7",
"xml-js": "^1.6.11"
},
"devDependencies": {
"@types/node": "^22.10.0",
"@types/express": "^5.0.0",
"@types/node": "^22.10.2",
"mongodb-memory-server": "^10.1.2",
"nodemon": "^3.1.7",
"prettier": "^3.4.1",
"nodemon": "^3.1.9",
"prettier": "^3.4.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
}
Expand Down
17 changes: 12 additions & 5 deletions examples/kitchensink/boot.ts → examples/kitchensink/src/boot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './load_env.js';
import express from 'express';
import http from 'http';
import { useExecutionCancellation } from 'graphql-yoga';
Expand All @@ -10,9 +9,8 @@ import { log } from '@unchainedshop/logger';
import setupTicketing, { ticketingModules } from '@unchainedshop/ticketing';
import { TicketingAPI } from '@unchainedshop/ticketing';

import serveStatic from 'serve-static';
import '@unchainedshop/plugins/lib/pricing/discount-half-price-manual.js';
import '@unchainedshop/plugins/lib/pricing/discount-100-off.js';
import '@unchainedshop/plugins/pricing/discount-half-price-manual.js';
import '@unchainedshop/plugins/pricing/discount-100-off.js';

import seed from './seed.js';
import ticketingServices from '@unchainedshop/ticketing/lib/services.js';
Expand Down Expand Up @@ -44,9 +42,15 @@ const start = async () => {
const cookies = cookie.parse(req.headers.get('cookie') || '');
return auth || cookies[UNCHAINED_COOKIE_NAME] || null;
},
enabled() {
return process.env.NODE_ENV === 'production';
},
}),
],
options: {
files: {
privateFileSharingMaxAge: 86400000,
},
payment: {
filterSupportedProviders: async ({ providers }) => {
return providers.sort((left, right) => {
Expand Down Expand Up @@ -76,7 +80,10 @@ const start = async () => {
createGoogleWalletPass: console.log,
});

app.use(serveStatic('static', { index: ['index.html'] }));
const fileUrl = new URL(import.meta.resolve('../static/index.html'));
app.use('/', async (req, res) => {
res.status(200).sendFile(fileUrl.pathname);
});

Dismissed Show dismissed Hide dismissed
await httpServer.listen({ port: process.env.PORT || 3000 });
log(`🚀 Server ready at http://localhost:${process.env.PORT || 3000}`);
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/kitchensink/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"esm": true
},
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"esModuleInterop": true,
Expand All @@ -19,7 +18,8 @@
"skipLibCheck": true,
"sourceMap": true,
"target": "esnext",
"baseUrl": "." // This must be specified if "paths" is.
"declarationDir": "./lib",
"rootDir": "./src"
},
"exclude": ["node_modules", "lib"]
}
23 changes: 19 additions & 4 deletions examples/minimal/boot.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import { startPlatform, setAccessToken } from '@unchainedshop/platform';
import baseModules from '@unchainedshop/plugins/lib/presets/base-modules.js';
import baseModules from '@unchainedshop/plugins/presets/base-modules.js';
// import connectBasePluginsToExpress from '@unchainedshop/plugins/presets/base-express.js';
import { connect } from '@unchainedshop/api/lib/fastify/index.js';
import { log } from '@unchainedshop/logger';
import { createLogger } from '@unchainedshop/logger';
import seed from './seed.js';
import Fastify from 'fastify';

const logger = createLogger('minimal');

function Logger(...args) {
this.args = args;
}
Logger.prototype.info = logger.info;
Logger.prototype.error = logger.error;
Logger.prototype.debug = logger.debug;
Logger.prototype.fatal = logger.error;
Logger.prototype.warn = logger.warn;
Logger.prototype.trace = logger.trace;
Logger.prototype.child = function () {
return new Logger();
};

const start = async () => {
const fastify = Fastify({
logger: true,
loggerInstance: new Logger(),
disableRequestLogging: true,
trustProxy: true,
});

Expand All @@ -35,7 +51,6 @@ const start = async () => {

try {
await fastify.listen({ port: process.env.PORT ? parseInt(process.env.PORT) : 3000 });
log(`🚀 Server ready at http://localhost:${process.env.PORT || 3000}`);
} catch (err) {
fastify.log.error(err);
process.exit(1);
Expand Down
11 changes: 6 additions & 5 deletions examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@
},
"dependencies": {
"@fastify/cookie": "^11.0.1",
"@fastify/session": "^11.0.1",
"@fastify/session": "^11.0.2",
"@unchainedshop/platform": "^3.0.0-alpha4",
"@unchainedshop/plugins": "^3.0.0-alpha4",
"fastify": "^5.1.0"
"connect-mongo": "^5.1.0",
"fastify": "^5.2.0"
},
"devDependencies": {
"@types/node": "^22.10.0",
"@types/node": "^22.10.2",
"mongodb-memory-server": "^10.0.0",
"nodemon": "^3.1.7",
"prettier": "^3.4.1",
"nodemon": "^3.1.9",
"prettier": "^3.4.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
}
Expand Down
Loading
Loading