Skip to content

Commit

Permalink
feat(ui): Introduce the svelte implementation of miniscrape UI
Browse files Browse the repository at this point in the history
  • Loading branch information
pestanko committed Apr 14, 2024
1 parent 54c120a commit 24de7ac
Show file tree
Hide file tree
Showing 41 changed files with 4,664 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ log/
bin/
!bin/.gitkeep

reports/
reports/

.DS_Store
node_modules
/build
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ services:
timeout: 5s
retries: 3
start_period: 10s

miniscrape-ui:
image: miniscrape-ui
build: ./miniscrape-ui
ports:
- 3000:3000
restart: on-failure
environment:
SERVICE_MINISCRAPE_URL: "http://miniscrape:8080"
healthcheck:
test: ["CMD", 'node', '-e', 'fetch("http://localhost:3000/healthz").then(r => process.exit(r.ok ? 0 : 1))']
interval: 10s
timeout: 5s
retries: 3
start_period: 10s

3 changes: 2 additions & 1 deletion internal/web/handlers/categories.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package handlers

import (
"net/http"

"github.com/pestanko/miniscrape/internal/models"
"github.com/pestanko/miniscrape/internal/scraper"
"github.com/pestanko/miniscrape/pkg/rest/webut"
"net/http"
)

// HandleCategories handler
Expand Down
10 changes: 10 additions & 0 deletions miniscrape-ui/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ENV config
ENV_NAME="local"

# Logging
LOG_PRETTY=true
LOG_LEVEL=debug
LOG_QUERIES=true

# Services
SERVICE_MINISCRAPE_URL="http://localhost:8080/"
13 changes: 13 additions & 0 deletions miniscrape-ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
31 changes: 31 additions & 0 deletions miniscrape-ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte'],
},
env: {
browser: true,
es2017: true,
node: true,
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
},
},
],
};
21 changes: 21 additions & 0 deletions miniscrape-ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
dist/
test-results/
package-lock.json
yarn.lock
vite.config.js.timestamp-*
/packages/create-svelte/template/CHANGELOG.md
/packages/package/test/**/package
/documentation/types.js
.env
.vercel_build_output
.svelte-kit
.cloudflare
.pnpm-debug.log
.netlify
.turbo
.vercel
.test-tmp
symlink-from
.idea/
1 change: 1 addition & 0 deletions miniscrape-ui/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions miniscrape-ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
10 changes: 10 additions & 0 deletions miniscrape-ui/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"useTabs": true,
"singleQuote": true,
"bracketSpacing": true,
"trailingComma": "all",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
44 changes: 44 additions & 0 deletions miniscrape-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# syntax=docker/dockerfile:1
# https://docs.docker.com/develop/develop-images/multistage-build/

ARG NODE_VERSION=20-slim

# BASE
FROM node:$NODE_VERSION AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /app

COPY ../package.json ../pnpm-lock.yaml ./

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# BUILD
FROM base AS build

WORKDIR /app

COPY . .

COPY --chown=node:node --from=base /app/node_modules ./node_modules

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

# RUNTIME
FROM node:$NODE_VERSION

WORKDIR /app

COPY --chown=node:node --from=build /app/package.json /app/pnpm-lock.yaml ./
COPY --chown=node:node --from=build /app/node_modules ./node_modules
COPY --chown=node:node --from=build /app/dist ./dist

EXPOSE 3000

USER node

CMD ["node", "dist/index.js"]
38 changes: 38 additions & 0 deletions miniscrape-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
57 changes: 57 additions & 0 deletions miniscrape-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "miniscrape-ui",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test": "vitest",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"devDependencies": {
"@mertasan/tailwindcss-variables": "^2.7.0",
"@savvywombat/tailwindcss-grid-areas": "^4.0.0",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-node": "^5.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/line-clamp": "^0.4.4",
"@types/eslint": "^8.56.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@vitest/coverage-v8": "^1.4.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.38",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vitest": "^1.2.0"
},
"dependencies": {
"axios": "^1.6.8",
"flowbite": "^2.3.0",
"flowbite-svelte": "^0.44.24",
"flowbite-svelte-icons": "^1.5.0",
"pino": "^8.19.0",
"pino-pretty": "^11.0.0",
"svelte-feather-icons": "^4.1.0",
"svelte-sonner": "^0.3.21"
}
}
Loading

0 comments on commit 24de7ac

Please sign in to comment.