Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rework #153

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .babelrc

This file was deleted.

10 changes: 6 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:prettier/recommended",
"prettier"
"eslint-config-prettier"
],
"plugins": ["prettier"],
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2020, // Allows for the parsing of modern ECMAScript features
Expand All @@ -17,14 +17,16 @@
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"no-unused-vars": "off",
"react/no-unescaped-entities": "off",
"prettier/prettier": [
"error",
{
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "always",
"printWidth": 100
"printWidth": 100,
"endOfLine": "auto"
}
]
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# testing
/coverage

/tools

# next.js
/.next/
/out/
Expand Down
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"singleQuote": true
}
21 changes: 0 additions & 21 deletions .storybook/main.js

This file was deleted.

83 changes: 0 additions & 83 deletions .storybook/preview.js

This file was deleted.

31 changes: 0 additions & 31 deletions .storybook/reactIntl.js

This file was deleted.

42 changes: 5 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
# Install dependencies only when needed
FROM node:16.17.1-alpine3.15 AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# COPY package.json yarn.lock ./
COPY package.json package-lock.json ./
# RUN yarn install --frozen-lockfile
RUN npm ci
# Production image, copy all the files and run next
FROM node:20

# Rebuild the source code only when needed
FROM node:16.17.1-alpine3.15 AS builder
WORKDIR /app
COPY . .

COPY --from=deps /app/node_modules ./node_modules
ENV NEXT_PUBLIC_STRAPI_API 'https://ergo-platform-cms-nvbpfiue6q-ez.a.run.app'
# RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
RUN npm run build && npm install --production --ignore-scripts --prefer-offline

# Production image, copy all the files and run next
FROM node:16.17.1-alpine3.15 AS runner
WORKDIR /app
RUN npm install -g npm@6
RUN npm install
RUN npm run build

ENV NODE_ENV production

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001

# You only need to copy next.config.js if you are NOT using the default configuration
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/entrypoint.sh ./entrypoint.sh
COPY --from=builder /app/next.config.js ./next.config.js

USER nextjs

EXPOSE 3000

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
ENV NEXT_TELEMETRY_DISABLED 1

RUN npx next telemetry disable

# CMD ["yarn", "start"]
ENTRYPOINT ["sh", "/app/entrypoint.sh"]
Expand Down
81 changes: 81 additions & 0 deletions api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { New } from 'types/new';

export const getNews = async (): Promise<New[]> => {
try {
const news = await fetch(
process.env.NEXT_PUBLIC_STRAPI_API +
'/api/posts?sort=date:desc&pagination[page]=1&pagination[pageSize]=5&populate=*&filters[type][$eq]=news'
);
const json = await news.json();
return json.data;
} catch (err) {
const result = (err as Error).message;
console.log(err);
// TODO: Add logger
throw Error(`Fetch News error ${result}`);
}
};

export const getExchanges = async (locale: string): Promise<any> => {
try {
const exchanges = await fetch(
process.env.NEXT_PUBLIC_STRAPI_API +
'/api/exchanges?sort=order:asc&populate=*&locale=' +
locale
);
const json = await exchanges.json();
return json.data;
} catch (err) {
const result = (err as Error).message;
console.log(err);
// TODO: Add logger
throw Error(`Fetch Exchanges error ${result}`);
}
};

export const getErgoPrice = async (): Promise<number> => {
try {
const price = await fetch(
'https://api.coingecko.com/api/v3/simple/price?ids=ergo&vs_currencies=USD'
);
const json: any = await price.json();
return json.ergo.usd;
} catch (err) {
const result = (err as Error).message;
console.log(err);
// TODO: Add logger
throw Error(`Fetch getErgoPrice error ${result}`);
}
};

export const getHashRate = async (): Promise<number> => {
try {
const hashRate = await fetch('https://api.ergoplatform.com/info/');
const json = await hashRate.json();
return json.hashRate;
} catch (err) {
const result = (err as Error).message;
console.log(err);
// TODO: Add logger
throw Error(`Fetch getHashRate error ${result}`);
}
};

export const getBlockInfo = async (): Promise<{
currentBlockReward: number;
difficulty: number;
}> => {
try {
const info = await fetch('https://api.ergoplatform.com/blocks');
const json = await info.json();
return {
currentBlockReward: json.items[0].minerReward / 1000000000,
difficulty: json.items[0].difficulty,
};
} catch (err) {
const result = (err as Error).message;
console.log(err);
// TODO: Add logger
throw Error(`Fetch getBlockInfo error ${result}`);
}
};
5 changes: 5 additions & 0 deletions assets/icons/arrow-big.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/icons/arrow-rt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/arrow-small-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/icons/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/icons/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/rotate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/socials/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/socials/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/socials/reddit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/socials/telegram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading