mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-28 15:55:19 +08:00
refactor(server): rename @affine/storage to @affine/server-native (#6682)
- Close https://github.com/toeverything/AFFiNE/issues/6680
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "affine_storage"
|
||||
name = "affine_server_native"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@affine/storage",
|
||||
"name": "@affine/server-native",
|
||||
"version": "0.14.0",
|
||||
"engines": {
|
||||
"node": ">= 10.16.0 < 11 || >= 11.8.0"
|
||||
@@ -10,13 +10,13 @@
|
||||
"types": "index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./storage.node",
|
||||
"require": "./server-native.node",
|
||||
"import": "./index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
},
|
||||
"napi": {
|
||||
"binaryName": "storage",
|
||||
"binaryName": "server-native",
|
||||
"targets": [
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
@@ -29,10 +29,7 @@
|
||||
"scripts": {
|
||||
"test": "node --test ./__tests__/**/*.spec.js",
|
||||
"build": "napi build --release --strip --no-const-enum",
|
||||
"build:debug": "napi build",
|
||||
"prepublishOnly": "napi prepublish -t npm",
|
||||
"artifacts": "napi artifacts",
|
||||
"version": "napi version"
|
||||
"build:debug": "napi build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "3.0.0-alpha.46",
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "@affine/storage",
|
||||
"name": "@affine/server-native",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"root": "packages/backend/storage",
|
||||
"sourceRoot": "packages/backend/storage/src",
|
||||
"root": "packages/backend/native",
|
||||
"sourceRoot": "packages/backend/native/src",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "nx:run-script",
|
||||
@@ -11,7 +11,7 @@ yarn
|
||||
### Build Native binding
|
||||
|
||||
```bash
|
||||
yarn workspace @affine/storage build
|
||||
yarn workspace @affine/server-native build
|
||||
```
|
||||
|
||||
### Run server
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine-test/kit": "workspace:*",
|
||||
"@affine/storage": "workspace:*",
|
||||
"@affine/server-native": "workspace:*",
|
||||
"@napi-rs/image": "^1.9.1",
|
||||
"@nestjs/testing": "^10.3.7",
|
||||
"@types/cookie-parser": "^1.4.7",
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
let storageModule: typeof import('@affine/storage');
|
||||
let serverNativeModule: typeof import('@affine/server-native');
|
||||
try {
|
||||
storageModule = await import('@affine/storage');
|
||||
serverNativeModule = await import('@affine/server-native');
|
||||
} catch {
|
||||
const require = createRequire(import.meta.url);
|
||||
storageModule =
|
||||
serverNativeModule =
|
||||
process.arch === 'arm64'
|
||||
? require('../../../storage.arm64.node')
|
||||
? require('../../../server-native.arm64.node')
|
||||
: process.arch === 'arm'
|
||||
? require('../../../storage.armv7.node')
|
||||
: require('../../../storage.node');
|
||||
? require('../../../server-native.armv7.node')
|
||||
: require('../../../server-native.node');
|
||||
}
|
||||
|
||||
export const mergeUpdatesInApplyWay = storageModule.mergeUpdatesInApplyWay;
|
||||
export const mergeUpdatesInApplyWay = serverNativeModule.mergeUpdatesInApplyWay;
|
||||
|
||||
export const verifyChallengeResponse = async (
|
||||
response: any,
|
||||
@@ -21,10 +21,10 @@ export const verifyChallengeResponse = async (
|
||||
resource: string
|
||||
) => {
|
||||
if (typeof response !== 'string' || !response || !resource) return false;
|
||||
return storageModule.verifyChallengeResponse(response, bits, resource);
|
||||
return serverNativeModule.verifyChallengeResponse(response, bits, resource);
|
||||
};
|
||||
|
||||
export const mintChallengeResponse = async (resource: string, bits: number) => {
|
||||
if (!resource) return null;
|
||||
return storageModule.mintChallengeResponse(resource, bits);
|
||||
return serverNativeModule.mintChallengeResponse(resource, bits);
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"path": "./tsconfig.node.json"
|
||||
},
|
||||
{
|
||||
"path": "../storage/tsconfig.json"
|
||||
"path": "../native/tsconfig.json"
|
||||
}
|
||||
],
|
||||
"ts-node": {
|
||||
|
||||
Reference in New Issue
Block a user