This is web app providing random presaved secret for users who have signed in using their polkdot wallet. It securely sign in user by asking wallet message sign requests and the signed message gets verified before a client session can be given to the browser. It supports both in-wallet and cross-wallet account switch, which will automatically override the previous account session when the switched account sign in successfully
- It's a production ready app based on nextjs ecosystem to drastically cutting off development effort
- It's using next-auth as opinonated authentication layer, it has fine tuned the session timeout and advanced secruity headers
- It uses Material UI as frontend library.
- Both frontend and backend code are almost fully covered by unit tests whereever possible
- The data persistence layer is AWS dynamodb for its simplicity in terms of dev and deployment
- The web app can be easily run locally connected to a local dynamodb, a cloud one, or deployed via Vercel
- being able to add secret by user
- authorization for user for secret that created by them, and others should not be able to see these
- integration tests such cypress could be done
Need nvm, node, yarn and docker (for local dynamodb)
Install yarn
globally
nvm use
npm i -g yarn
To set up local dependencies and stay consistent with CI use the yarn
package manager
yarn install
To start a local server:
- Create local environment
cp .env.template .env.local
- Edit
.env.local
, set env variable value. - Run
yarn dev
. - Goto http://localhost:3000
Run script below.
yarn start:db:local
yarn init:local:db
yarn dev
-
Test blocked with
message Determing test suites to run...
, After waiting for a period of time, the following error is output.Exception in thread "main" java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8100
This is because the local dynamodb test is enabled and requires an available port. This problem will occur if it is occupied. This can be fixed by modifying the port numbers of
DYNAMODB_ENDPOINT
andDYNAMODB_PORT
in.env.test
Note: If dynamodb-local is enabled through docker, it will also cause this problem, please modify our test port to avoid this problem
-
Initialize dynamodb
- create environment file
cp .env.template .env.prod
, and set env variable value - run
yarn init:prod:db
- create environment file
-
go to vercel to create a new project
-
connect and choose to import a git repository
-
type a project name and choose
Next.js
as framework preset -
add environment variables
- S_AWS_ACCESS_KEY, S_AWS_SECRET_KEY, S_AWS_REGION, for dynamodb access
- JWT_SECRET, can be generate use the command:
node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"
-
click to deploy