Skip to content

Commit

Permalink
Merge branch 'develop' into uploaded_files_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Dec 12, 2022
2 parents fd1af11 + 461a8e2 commit 72c6ae2
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _templates/service/new/.eslintrc.json.ejs.t
@@ -0,0 +1,7 @@
---
to: ee/apps/<%= name %>/.eslintrc.json
---
{
"extends": ["@rocket.chat/eslint-config"],
"ignorePatterns": ["**/dist"]
}
51 changes: 51 additions & 0 deletions _templates/service/new/package.json.ejs.t
@@ -0,0 +1,51 @@
---
to: ee/apps/<%= name %>/package.json
---
{
"name": "@rocket.chat/<%= name.toLowerCase() %>",
"private": true,
"version": "0.1.0",
"description": "Rocket.Chat service",
"scripts": {
"build": "tsc -p tsconfig.json",
"ms": "TRANSPORTER=${TRANSPORTER:-TCP} MONGO_URL=${MONGO_URL:-mongodb://localhost:3001/meteor} ts-node --files src/service.ts",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src",
"typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json"
},
"keywords": [
"rocketchat"
],
"author": "Rocket.Chat",
"dependencies": {
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "0.31.22",
"@rocket.chat/model-typings": "workspace:^",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@rocket.chat/string-helpers": "0.31.22",
"@types/node": "^14.18.21",
"ejson": "^2.2.2",
"eventemitter3": "^4.0.7",
"fibers": "^5.0.3",
"mem": "^8.1.1",
"moleculer": "^0.14.21",
"mongodb": "^4.12.1",
"nats": "^2.4.0",
"pino": "^8.4.2",
"polka": "^0.5.2"
},
"devDependencies": {
"@rocket.chat/eslint-config": "workspace:^",
"@types/eslint": "^8.4.10",
"@types/polka": "^0.5.4",
"eslint": "^8.29.0",
"ts-node": "^10.9.1",
"typescript": "~4.5.5"
},
"main": "./dist/ee/apps/<%= name %>/src/service.js",
"files": [
"/dist"
]
}

43 changes: 43 additions & 0 deletions _templates/service/new/service.ejs.t
@@ -0,0 +1,43 @@
---
to: ee/apps/<%= name %>/src/service.ts
---
import type { Document } from 'mongodb';
import polka from 'polka';

import { api } from '../../../../apps/meteor/server/sdk/api';
import { broker } from '../../../../apps/meteor/ee/server/startup/broker';
import { Collections, getCollection, getConnection } from '../../../../apps/meteor/ee/server/services/mongo';
import { registerServiceModels } from '../../../../apps/meteor/ee/server/lib/registerServiceModels';

const PORT = process.env.PORT || 3034;

(async () => {
const db = await getConnection();

const trash = await getCollection<Document>(Collections.Trash);

registerServiceModels(db, trash);

api.setBroker(broker);

// need to import service after models are registered
const { <%= h.changeCase.pascalCase(name) %> } = await import('./<%= h.changeCase.pascalCase(name) %>');

api.registerService(new <%= h.changeCase.pascalCase(name) %>());

await api.start();

polka()
.get('/health', async function (_req, res) {
try {
await api.nodeList();
res.end('ok');
} catch (err) {
console.error('Service not healthy', err);

res.writeHead(500);
res.end('not healthy');
}
})
.listen(PORT);
})();
16 changes: 16 additions & 0 deletions _templates/service/new/servicesClass.ejs.t
@@ -0,0 +1,16 @@
---
to: ee/apps/<%= name %>/src/<%= h.changeCase.pascalCase(name) %>.ts
---
import { ServiceClass } from '../../../../apps/meteor/server/sdk/types/ServiceClass';

export class <%= h.changeCase.pascalCase(name) %> extends ServiceClass {
protected name = '<%= name %>';

constructor() {
super();

// your stuff
}

// more stuff
}
34 changes: 34 additions & 0 deletions _templates/service/new/tsconfig.json.ejs.t
@@ -0,0 +1,34 @@
---
to: ee/apps/<%= name %>/tsconfig.json
---
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"target": "es2018",
"lib": ["esnext", "dom"],
"allowJs": true,
"checkJs": false,
"incremental": true,

/* Strict Type-Checking Options */
"noImplicitAny": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"strictFunctionTypes": false,

/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": false,

/* Module Resolution Options */
"outDir": "./dist",
"importsNotUsedAsValues": "preserve",
"declaration": false,
"declarationMap": false
},
"files": ["./src/service.ts"],
"include": ["../../../apps/meteor/definition/externals/meteor"],
"exclude": ["./dist"]
}

0 comments on commit 72c6ae2

Please sign in to comment.