Skip to content

Commit

Permalink
chore: package publish preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Oct 30, 2024
1 parent 68152fb commit 759398b
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 42 deletions.
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:lts-hydrogen

WORKDIR /dist

COPY package*.json ./

RUN npm install

COPY . /dist

RUN npm run build

ENTRYPOINT ["/bin/sh", "-c", "npm run start:prod"]
60 changes: 19 additions & 41 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
# 🚀 GovTool Delegation Pillar Backend 🚀

The `@intersect.mbo/govtool-delegation-pillar-backend` is a NestJS application that serves as the backend for the GovTool Voting Pillar. It provides the API endpoints for the frontend to interact with the db-sync.

## Table of content:

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Running the app](#running-the-app)
- [Test](#test)

## Prerequisites

- Node.js installed - [Download link](https://nodejs.org/en/download/).
- PostgreSQL installed (if running locally without Docker) - [Download link](https://www.postgresql.org/).
- Docker and Docker Compose installed (for Docker environment) - [Download link](https://docs.docker.com/get-started/)

## Installation

Expand All @@ -34,6 +23,9 @@ $ npm install

## Running the app

To run the application locally, you need to have Node.js installed.
Copy `.env.example` to `.env` and fill in the required environment variables.

```bash
# development
$ npm run start
Expand All @@ -57,17 +49,3 @@ $ npm run test:e2e
# test coverage
$ npm run test:cov
```

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](LICENSE).
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "backend",
"name": "@intersect.mbo/govtool-voting-pillar-backend",
"version": "0.0.1",
"description": "",
"author": "",
Expand Down
193 changes: 193 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# @intersect.mbo/govtool-delegation-pillar

The `@intersect.mbo/govtool-delegation-pillar` is a React.js package that provides the essential logic and UI components for managing and conducting delegation within a Cardano governance.

## Table of content:

- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [Prerequisites](#prerequisites)
- [Running locally](#running-locally)

## Installation

To install this pacakge, use npm or yarn:

### `npm install @intersect.mbo/govtool-delegation-pillar`

or

### `yarn add @intersect.mbo/govtool-delegation-pillar`

## Usage

After installation, you can import the component and use it in your project.

#### This is an example of implementing a package in a [NextJs](https://nextjs.org/) application

```tsx
'use client';
import dynamic from 'next/dynamic';
import { useAppContext } from '@/context';

const DelegationPillar = dynamic(
() => import('@intersect.mbo/govtool-delegation-pillar'),
{
ssr: false,
}
);

export default function Page() {
const {
apiUrl,
walletApi,
validationApiUrl,
cExplorerBaseUrl,
epochParams,
connectWallet,
openFeedbackWindow,
addSuccessAlert,
addErrorAlert,
validateMetadata,
generateMetadata,
createJsonLD,
createHash,
...context
// Or from any other context you need
} = useAppContext();

return (
<DelegationPillar
walletApi={walletApi}
apiUrl={process.env.NEXT_PUBLIC_DELEGATIOn_API_URL}
validationApiUrl={process.env.NEXT_PUBLIC_DELEGATION_API_URL}
cExplorerBaseUrl={process.env.NEXT_PUBLIC_DELEGATIOn_BASE_URL}
epochParams={epochParams}
connectWallet={connectWallet}
openFeedbackWindow={openFeedbackWindow}
addSuccessAlert={addSuccessAlert}
addErrorAlert={addErrorAlert}
validateMetadata={validateMetadata}
generateMetadata={generateMetadata}
createJsonLD={createJsonLD}
createHash={createHash}
/>
);
}
```

#### Example of Implementing a Package Using CommonJS Modules (CJS):

```tsx
import React from 'react';
import { useAppContext } from '@/context';

const VotingPillar = React.lazy(
() => import('@intersect.mbo/govtool-delegation-pillar/cjs')
);

export const VotingComponent = () => {
const {
apiUrl,
walletApi,
validationApiUrl,
cExplorerBaseUrl,
epochParams,
connectWallet,
openFeedbackWindow,
addSuccessAlert,
addErrorAlert,
validateMetadata,
generateMetadata,
createJsonLD,
createHash,
...context
// Or from any other context you need
} = useAppContext();

return (
<VotingPillar
walletApi={walletApi}
apiUrl={process.env.NEXT_PUBLIC_DELEGATION_API_URL}
validationApiUrl={process.env.NEXT_PUBLIC_VALIDATION_API_URL}
cExplorerBaseUrl={process.env.NEXT_PUBLIC_CEXPLORER_BASE_URL}
epochParams={epochParams}
connectWallet={connectWallet}
openFeedbackWindow={openFeedbackWindow}
addSuccessAlert={addSuccessAlert}
addErrorAlert={addErrorAlert}
validateMetadata={validateMetadata}
generateMetadata={generateMetadata}
createJsonLD={createJsonLD}
createHash={createHash}
/>
);
};
```

## Project Structure

```govtool-delegation-pillar/frontend
├── dist
├── jest.config.cjs
├── node_modules
├── package.json
├── package-lock.json
├── public
├── README.md
├── rollup.config.mjs
├── setupTests.ts
├── src
│ ├── components
│ ├── consts
│ ├── context
│ ├── DelegationPillarRoutes.tsx
│ ├── DelegationPillar.tsx
│ ├── features
│ ├── hooks
│ ├── i18n
│ ├── index.tsx
│ ├── pages
│ ├── react-app-env.d.ts
│ ├── services
│ ├── theme
│ ├── types
│ └── utils
└── tsconfig.json
└── yarn.lock
```

- **components/**: The `@intersect.mbo/govtool-delegation-pillar` components.
- **consts/**: Constants for the application.
- **context/**: Context for global application state.
- **features/**: Features for the application.
- **hooks/**: Custom hooks.
- **i18n/**: Internationalization configuration.
- **pages/**: Application pages.
- **services/**: Services for fetching data.
- **stories/**: Storybook stories.
- **theme/**: Theme configuration.
- **types/**: Typescript types.
- **utils/**: Utility functions.
- **rollup.config.js**: Configuration for the Rollup bundler.

## Prerequisites

Before starting, please ensure you have the following:

- Node.js and npm - Latest versions. You can download them from [here](https://nodejs.org/en/download/).

## Running locally

To run the application locally, you need to have Node.js installed.
Copy `.env.example` to `.env` and fill in the required environment variables.

Run the Voting Pillar backend server.

Start the frontend server:

```bash
npm install
npm start
```

0 comments on commit 759398b

Please sign in to comment.