Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into uploaded_files_fix
- Loading branch information
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
to: ee/apps/<%= name %>/.eslintrc.json | ||
--- | ||
{ | ||
"extends": ["@rocket.chat/eslint-config"], | ||
"ignorePatterns": ["**/dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
} |