Skip to content

Commit

Permalink
Merge branch 'release-2.0.0' into credential
Browse files Browse the repository at this point in the history
  • Loading branch information
tushar5526 committed Jul 11, 2023
2 parents 05722ed + c41f19c commit 3a964c0
Show file tree
Hide file tree
Showing 83 changed files with 9,403 additions and 37 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ IMAGES := dockerhub/sunbird-rc-core dockerhub/sunbird-rc-nginx dockerhub/sunbird
dockerhub/sunbird-rc-public-key-service dockerhub/sunbird-rc-keycloak dockerhub/sunbird-rc-certificate-api \
dockerhub/sunbird-rc-certificate-signer dockerhub/sunbird-rc-notification-service dockerhub/sunbird-rc-claim-ms \
dockerhub/sunbird-rc-digilocker-certificate-api dockerhub/sunbird-rc-bulk-issuance dockerhub/sunbird-rc-metrics \
dockerhub/sunbird-rc-credentials-service dockerhub/sunbird-rc-identity-service
dockerhub/sunbird-rc-identity-service dockerhub/sunbird-rc-credential-schema dockerhub/sunbird-rc-credentials-service

build: java/registry/target/registry.jar
echo ${SOURCES}
Expand All @@ -23,8 +23,10 @@ build: java/registry/target/registry.jar
make -C services/digilocker-certificate-api docker
make -C services/bulk_issuance docker
docker build -t dockerhub/sunbird-rc-nginx .
make -C services/credentials-service/ docker
make -C services/identity-service/ docker
make -C services/credential-schema docker
make -C services/credentials-service/ docker


java/registry/target/registry.jar: $(SOURCES)
echo $(SOURCES)
Expand Down Expand Up @@ -71,8 +73,9 @@ test: build
make -C services/public-key-service test
make -C services/context-proxy-service test
make -C services/bulk_issuance test
make -C services/credentials-service test
make -C services/identity-service test
make -C services/credential-schema test
make -C services/credentials-service test

clean:
@rm -rf target || true
Expand Down
3 changes: 3 additions & 0 deletions services/credential-schema/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.env
dist
13 changes: 13 additions & 0 deletions services/credential-schema/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DATABASE_URL=""
SHADOW_DATABASE_URL=""

# Auth related vars
JWKS_URI=""
ENABLE_AUTH=false

# Core Service Vars
IDENTITY_BASE_URL= # URL of the identity service to facilitate DID creation

# Service VARS
PORT=3000
SCHEMA_BASE_URL=
25 changes: 25 additions & 0 deletions services/credential-schema/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir : __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
38 changes: 38 additions & 0 deletions services/credential-schema/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

#Environment files
.env
5 changes: 5 additions & 0 deletions services/credential-schema/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2
}
21 changes: 21 additions & 0 deletions services/credential-schema/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:16 AS install
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn

FROM node:16 as build
WORKDIR /app
COPY prisma ./prisma/
COPY --from=install /app/node_modules ./node_modules
RUN npx prisma generate
COPY . .
RUN yarn build

FROM node:16
WORKDIR /app
COPY --from=build /app/dist ./dist
COPY --from=build /app/package*.json ./
COPY --from=build /app/prisma ./prisma
COPY --from=build /app/node_modules ./node_modules
EXPOSE 3000
CMD [ "npm", "run", "start:migrate:prod" ]
13 changes: 13 additions & 0 deletions services/credential-schema/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16 AS install
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn

FROM node:16 as test
WORKDIR /app
COPY prisma ./prisma/
COPY --from=install /app/node_modules ./node_modules
RUN npx prisma generate
COPY . .
EXPOSE 3000
CMD [ "yarn", "test:migrate"]
22 changes: 22 additions & 0 deletions services/credential-schema/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
IMAGE:=dockerhub/sunbird-rc-credential-schema

.PHONY: docker publish test

docker:
@docker build -t $(IMAGE) .

publish:
@docker push $(IMAGE)

test:
# Resetting vault of identity-service before running the tests
make -C ../identity-service stop
make -C ../identity-service vault-reset
# Creating an external docker network to connnect services in different compose
@docker network create rcw-test || echo ""
# Starting dependent services
make -C ../identity-service compose-init
@docker-compose -f docker-compose-test.yml down
@docker-compose -f docker-compose-test.yml up --build --abort-on-container-exit
make -C ../identity-service stop
make -C ../identity-service vault-reset
86 changes: 86 additions & 0 deletions services/credential-schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Credential Schema Microservice

## Description

[Nest](https://github.com/nestjs/nest) based CRUD APIs for handling the schemas of different verifiable credentials used for implementing the [Unified Learner's Passbook](https://github.com/Unified-Learners-Passbook) in the state of Uttar Pradesh, India.

## Installation

```bash

$ npm install

```
OR
```bash

$ npx yarn

```
## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

OR

```bash
# development
$ npx yarn run start

# watch mode
$ npx yarn run start:dev

# production mode
$ npx yarn run start:prod
```

## Test

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

OR

```bash
# unit tests
$ npx yarn run test

# e2e tests
$ npx yarn run test:e2e

# test coverage
$ npx yarn run test:cov
```

## Stay in touch

- Authors - [Yash Mittal](https://github.com/techsavvyash) and [Chakshu Gautam](https://github.com/ChakshuGautam)
- Website - [https://nestjs.com](https://nestjs.com/)

## License

Nest is [MIT licensed](LICENSE).

## Reference Links

- [W3C Credential Schema (Currently being used)](https://w3c-ccg.github.io/vc-json-schemas/schema/2.0/schema.json)
- [W3C Credential Schema (initially used)](https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json)
- [W3C JSON Schemas Website](https://w3c-ccg.github.io/vc-json-schemas/)
- [API Documentation](https://github.com/Sunbird-RC/sunbird-rc-core/tree/main/api-documentation)
35 changes: 35 additions & 0 deletions services/credential-schema/docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3'

services:
db-test:
image: postgres:12
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 10s
timeout: 5s
retries: 5
networks:
test:

credential-schema-test:
build:
context: .
dockerfile: Dockerfile.test
depends_on:
db-test:
condition: service_healthy
environment:
DATABASE_URL: postgres://postgres:postgres@db-test:5432/postgres
IDENTITY_BASE_URL: "http://identity-service:3332"
ENABLE_AUTH: "false"
networks:
test:
rcw-test:

networks:
rcw-test:
external: true
test:
39 changes: 39 additions & 0 deletions services/credential-schema/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3'

services:
db:
image: postgres:12
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
volumes:
- data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 10s
timeout: 5s
retries: 5

credential-schema:
image: cred
build: .
depends_on:
db:
condition: service_healthy
ports:
- '3333:3333'
environment:
DATABASE_URL: postgres://postgres:postgres@db:5432/postgres
IDENTITY_BASE_URL: "http://identity-service:3332"
ENABLE_AUTH: "false"
networks:
rcw-test:
default:


networks:
rcw-test:
external: true

volumes:
data:
5 changes: 5 additions & 0 deletions services/credential-schema/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
Loading

0 comments on commit 3a964c0

Please sign in to comment.