-
Notifications
You must be signed in to change notification settings - Fork 73
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 renovate/typescript-5.x
- Loading branch information
Showing
26 changed files
with
1,097 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
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,20 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
module.exports = { | ||
rules: { | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
patterns: ['@client/*', '!@client/v2-events', '!@client/components'] | ||
} | ||
] | ||
} | ||
} |
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,12 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
|
||
export function noop() {} |
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,11 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
export const V2_ROOT_ROUTE = '/v2' |
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,12 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
|
||
export function noop() {} |
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 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
|
||
import React from 'react' | ||
|
||
export function Workqueues() { | ||
return <div>This is where it starts from</div> | ||
} |
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,24 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
module.exports = { | ||
extends: '../../.eslintrc.js', | ||
env: { | ||
es6: true | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.ts'], | ||
parserOptions: { | ||
project: ['./tsconfig.json'] | ||
} | ||
} | ||
] | ||
} |
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,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,12 @@ | ||
ARG BRANCH=develop | ||
FROM opencrvs/ocrvs-base:${BRANCH} | ||
|
||
USER node | ||
|
||
WORKDIR /app/packages/events | ||
COPY --chown=node:node packages/events/*.json /app/packages/events/ | ||
RUN yarn install --frozen-lockfile | ||
COPY --chown=node:node packages/events /app/packages/events | ||
RUN yarn build | ||
|
||
CMD [ "yarn", "start:prod" ] |
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,21 @@ | ||
*.md | ||
*.yml | ||
*.yaml | ||
.vscode | ||
**/.git | ||
**/test | ||
|
||
# From root | ||
**/node_modules | ||
**/coverage | ||
**/.DS_Store | ||
**/.env | ||
**/*.log | ||
.secrets/* | ||
data | ||
grafana | ||
|
||
# Exclude unused packages | ||
packages/* | ||
!packages/commons | ||
!packages/events |
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 @@ | ||
{ | ||
"name": "@opencrvs/events", | ||
"version": "1.5.0", | ||
"description": "OpenCRVS Events service", | ||
"license": "MPL-2.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", | ||
"start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", | ||
"test": "yarn test:compilation && vitest run", | ||
"lint": "eslint -c .eslintrc.js --fix ./src --max-warnings=0", | ||
"precommit": "lint-staged", | ||
"test:compilation": "tsc --noEmit", | ||
"build": "tsc", | ||
"build:clean": "rm -rf build" | ||
}, | ||
"dependencies": { | ||
"@opencrvs/commons": "^1.3.0", | ||
"@trpc/server": "^11.0.0-rc.532", | ||
"app-module-path": "^2.2.0", | ||
"envalid": "^8.0.0", | ||
"mongodb": "6.9.0", | ||
"superjson": "1.9.0-0", | ||
"tsconfig-paths": "^3.13.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.5.0", | ||
"@typescript-eslint/parser": "^4.5.0", | ||
"cross-env": "^7.0.0", | ||
"eslint": "^7.11.0", | ||
"vite-tsconfig-paths": "^3.5.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.17.3", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"lint-staged": "^15.0.0", | ||
"mongodb-memory-server": "^10.1.2", | ||
"nodemon": "^3.0.0", | ||
"prettier": "2.8.8", | ||
"ts-jest": "27.1.4", | ||
"ts-node": "^6.1.1", | ||
"typescript": "4.9.5", | ||
"vitest": "^2.1.5" | ||
}, | ||
"lint-staged": { | ||
"src/**/*.{ts,graphql}": [ | ||
"prettier --write", | ||
"eslint -c .eslintrc.js --fix" | ||
] | ||
} | ||
} |
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 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
|
||
import { cleanEnv, url } from 'envalid' | ||
|
||
export const env = cleanEnv(process.env, { | ||
MONGO_URL: url({ devDefault: 'mongodb://localhost/events' }) | ||
}) |
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,48 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
import { vi } from 'vitest' | ||
import { appRouter, t } from './router' | ||
import { | ||
setupServer, | ||
getClient, | ||
resetServer | ||
} from './storage/__mocks__/mongodb' | ||
|
||
const { createCallerFactory } = t | ||
|
||
vi.mock('@events/storage/mongodb') | ||
|
||
beforeAll(async () => { | ||
await setupServer() | ||
}) | ||
|
||
afterEach(async () => { | ||
resetServer() | ||
}) | ||
|
||
test('creating a declaration is an idempotent operation', async () => { | ||
const createCaller = createCallerFactory(appRouter) | ||
|
||
const caller = createCaller({}) | ||
const db = await getClient() | ||
|
||
await caller.event.create({ | ||
transactionId: '1', | ||
record: { type: 'birth', fields: [] } | ||
}) | ||
|
||
await caller.event.create({ | ||
transactionId: '1', | ||
record: { type: 'birth', fields: [] } | ||
}) | ||
|
||
expect(await db.collection('events').find().toArray()).toHaveLength(1) | ||
}) |
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,25 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-unassigned-import | ||
import '@opencrvs/commons/monitoring' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
require('app-module-path').addPath(require('path').join(__dirname, '../')) | ||
|
||
import { appRouter } from './router' | ||
import { createHTTPServer } from '@trpc/server/adapters/standalone' | ||
|
||
const server = createHTTPServer({ | ||
router: appRouter | ||
}) | ||
|
||
server.listen(5555) |
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,45 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
|
||
import { initTRPC } from '@trpc/server' | ||
import superjson from 'superjson' | ||
import { z } from 'zod' | ||
import { createEvent, EventInput, getEventById } from './service/events' | ||
|
||
export const t = initTRPC.create({ | ||
transformer: superjson | ||
}) | ||
|
||
const router = t.router | ||
const publicProcedure = t.procedure | ||
|
||
/** | ||
* @public | ||
*/ | ||
export type AppRouter = typeof appRouter | ||
|
||
export const appRouter = router({ | ||
event: router({ | ||
create: publicProcedure | ||
.input( | ||
z.object({ | ||
transactionId: z.string(), | ||
record: EventInput | ||
}) | ||
) | ||
.mutation(async (options) => { | ||
return createEvent(options.input.record, options.input.transactionId) | ||
}), | ||
get: publicProcedure.input(z.string()).query(async ({ input }) => { | ||
return getEventById(input) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.