Просмотр исходного кода

:tada: create magnolia project

Jeremy Zheng 1 неделя назад
Родитель
Сommit
74e6f720e3

+ 0 - 23
DEVELOPMENT.md

@@ -1,23 +0,0 @@
-# Development
-
-## For local dev
-
-- Download [asdf](https://github.com/asdf-vm/asdf/releases) and put in into your `/usr/local/bin` folder.
-
-- Install Nodejs & Php
-
-```bash
-
-sudo apt -y install dirmngr gpg curl gawk
-
-asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
-asdf install nodejs 24.11.1
-node -v
-npm -v
-
-# https://github.com/asdf-community/asdf-php
-sudo apt -y install plocate
-asdf plugin add php https://github.com/asdf-community/asdf-php.git
-asdf install php 8.5.0
-php -v
-```

+ 3 - 0
magnolia/.env.example

@@ -0,0 +1,3 @@
+PORT=3000
+OPS_TOKEN="change-me"
+LOG_LEVEL="debug"

+ 4 - 0
magnolia/.gitignore

@@ -0,0 +1,4 @@
+/dist/
+/node_modules/
+/package-lock.json
+/.env

+ 8 - 0
magnolia/3rd.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+
+npm install --save express dotenv pino pino-http
+npm install --save-dev typescript @types/express @types/node
+
+exit 0

+ 9 - 0
magnolia/README.md

@@ -0,0 +1,9 @@
+# MCP server
+
+## Usage
+
+    ```bash
+    npm install
+    touch .env # .env.example
+    npm run dev
+    ```

+ 27 - 0
magnolia/package.json

@@ -0,0 +1,27 @@
+{
+  "name": "magnolia",
+  "version": "2026.8.18",
+  "private": true,
+  "description": "MCP server",
+  "main": "index.js",
+  "scripts": {
+    "dev": "tsx --watch src/index.ts",
+    "build": "tsc"
+  },
+  "keywords": [],
+  "author": "Ven.Visuddhinanda <visuddhinanda@gmail.com>",
+  "license": "MIT",
+  "type": "module",
+  "devDependencies": {
+    "@types/express": "^5.0.6",
+    "@types/node": "^26.2.0",
+    "tsx": "^4.23.12",
+    "typescript": "^7.0.2"
+  },
+  "dependencies": {
+    "dotenv": "^17.4.2",
+    "express": "^5.2.1",
+    "pino": "^10.3.1",
+    "pino-http": "^11.0.0"
+  }
+}

+ 5 - 0
magnolia/src/handlers/index.ts

@@ -0,0 +1,5 @@
+import { type Request, type Response } from "express";
+
+export const heartbeat = (req: Request, res: Response) => {
+  res.status(200).json({ createdAt: new Date() });
+};

+ 26 - 0
magnolia/src/index.ts

@@ -0,0 +1,26 @@
+import express, { type Express, type Request, type Response } from "express";
+import dotenv from "dotenv";
+import { pinoHttp } from "pino-http";
+
+import { heartbeat } from "./handlers/index.ts";
+
+dotenv.config();
+
+const app: Express = express();
+const PORT = process.env.PORT || 3000;
+
+const logging = pinoHttp({});
+logging.logger.level = process.env.LOG_LEVEL || "info";
+app.use(express.json());
+app.use(logging);
+
+app.get("/heartbeat", heartbeat);
+app.get("/", (req: Request, res: Response) => {
+  req.log.debug("Hello");
+
+  res.status(200).json({ message: "Hello from TypeScript Express!" });
+});
+
+app.listen(PORT, () => {
+  logging.logger.info(`Server is running at http://localhost:${PORT}`);
+});

+ 53 - 0
magnolia/tsconfig.json

@@ -0,0 +1,53 @@
+{
+  // Visit https://aka.ms/tsconfig to read more about this file
+  "compilerOptions": {
+    // File Layout
+    "rootDir": "./src",
+    "outDir": "./dist",
+
+    // Environment Settings
+    // See also https://aka.ms/tsconfig/module
+    "module": "nodenext",
+    "target": "esnext",
+    "types": [],
+    // For nodejs:
+    // "lib": ["esnext"],
+    // "types": ["node"],
+    // and npm install -D @types/node
+
+    // Other Outputs
+    "sourceMap": false,
+    "declaration": false,
+    "declarationMap": false,
+    "removeComments": true,
+
+    // Stricter Typechecking Options
+    "noUncheckedIndexedAccess": true,
+    "exactOptionalPropertyTypes": true,
+
+    // Style Options
+    // "noImplicitReturns": true,
+    // "noImplicitOverride": true,
+    // "noUnusedLocals": true,
+    // "noUnusedParameters": true,
+    // "noFallthroughCasesInSwitch": true,
+    // "noPropertyAccessFromIndexSignature": true,
+
+    // Recommended Options
+    "strict": true,
+    "jsx": "react-jsx",
+    "verbatimModuleSyntax": true,
+    "isolatedModules": true,
+    "noUncheckedSideEffectImports": true,
+    "moduleDetection": "force",
+    "skipLibCheck": true,
+
+    "moduleResolution": "nodenext",
+    "allowImportingTsExtensions": true,
+    "rewriteRelativeImportExtensions": true,
+    // "rewriteRelativeImportExtensions": true,
+    // "erasableSyntaxOnly": true,
+    // "noEmit": true,
+    "esModuleInterop": true
+  }
+}