Skip to content

Commit

Permalink
refactor!: new data structure
Browse files Browse the repository at this point in the history
- codes are now detatched from actual app runtime
- scraper cli as npx command
  • Loading branch information
rayriffy committed Feb 10, 2024
1 parent 1290b31 commit 84f23f1
Show file tree
Hide file tree
Showing 192 changed files with 459 additions and 4,607 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/deploys.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: runtime

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: rayriffy
password: ${{ secrets.GITHUB_TOKEN }}
- name: buildx
uses: docker/setup-buildx-action@v2
- name: build-and-push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/rayriffy/riffyh-runtime
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
build
.svelte-kit
package
.env
.env.*
!.env.example
Expand All @@ -14,4 +14,5 @@ data
.urami
stats.html
pnpm-lock.yaml
yarn.lock
yarn.lock
dist
Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions commons/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@riffyh/commons",
"main": "src/index.ts",
"private": true
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tools/backup.ts → commons/src/functions/getHentaiFromNH.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import kebabCase from 'lodash.kebabcase'
import kebabCase from 'lodash/kebabCase'

import type { Hentai } from '../src/core/@types/Hentai'
import type { Hentai } from '../@types/Hentai'

export const backupFetch = async (id: string | number): Promise<Hentai> => {
export const getHentaiFromNH = async (id: string | number): Promise<Hentai> => {
const data = await fetch(`https://nhentai.net/api/gallery/${id}`).then(o => {
if (o.ok) return o.json() as Promise<Hentai>
else throw o
})

return {
id: data.id,
id: Number(data.id),
media_id: data.media_id,
title: data.title,
images: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import kebabCase from 'lodash.kebabcase'
import kebabCase from 'lodash/kebabCase'

import type { Hentai } from '../@types/Hentai'
import type { Image } from '../@types/Image'
Expand Down
20 changes: 20 additions & 0 deletions commons/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// constants
export { hifuminHentaiQuery } from './constants/hifuminHentaiQuery'
export { itemsPerPage } from './constants/itemsPerPage'

// functions
export { getHentaiFromNH } from './functions/getHentaiFromNH'
export { hifuminHentaiToHentai } from './functions/hifuminHentaiToHentai'

// types
export type { DatabaseCode } from './@types/DatabaseCode'
export type { DatabaseTag } from './@types/DatabaseTag'
export type { Hentai } from './@types/Hentai'
export type { HifuminHentai } from './@types/HifuminHentai'
export type { HifuminImage } from './@types/HifuminImage'
export type { HifuminSingleResponse } from './@types/HifuminSingleResponse'
export type { HifuminTag } from './@types/HifuminTag'
export type { Image } from './@types/Image'
export type { NHHentai } from './@types/NHHentai'
export type { Tag } from './@types/Tag'
export type { TagType } from './@types/TagType'
84 changes: 10 additions & 74 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,19 @@
{
"name": "svelte",
"version": "0.0.1",
"author": "Phumrapee Limpianchop <[email protected]>",
"repository": {
"type": "git",
"url": "git+https://github.com/rayriffy/rayriffy-h.git"
},
"bugs": {
"url": "https://github.com/rayriffy/rayriffy-h/issues"
},
"homepage": "https://h.rayriffy.com",
"license": "MIT",
"private": true,
"scripts": {
"prepare": "prisma generate || true",
"dev": "vite dev",
"build": "vite build && bun tools/patchSW.ts",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"format": "prettier --write \"**/*.{ts,tsx,md,astro,svelte}\"",
"fetch:data": "bun tools/fetchData.ts",
"sync:data": "bun tools/syncData.ts",
"patch:sharp": "patch node_modules/sharp/install/libvips.js < patches/sharp.patch",
"prisma:generate": "prisma generate",
"prisma:commit": "prisma migrate dev",
"prisma:deploy": "prisma migrate deploy",
"sync": "bun run fetch:data && bun run sync:data"
},
"trustedDependencies": [
"prettier"
"name": "riffyh",
"version": "1.0.0",
"workspaces": [
"web/",
"scraper/",
"commons/"
],
"type": "module",
"dependencies": {
"@nanostores/persistent": "0.9.1",
"@tanstack/svelte-query": "5.17.1",
"@trpc/client": "10.45.0",
"@trpc/server": "10.45.0",
"@urami/core": "1.2.3",
"@urami/svelte": "1.1.1",
"cookie": "0.6.0",
"destr": "2.0.2",
"devalue": "4.3.2",
"lodash.kebabcase": "4.1.1",
"nanostores": "0.9.5",
"p-queue": "7.4.1",
"set-cookie-parser": "2.6.0",
"sharp": "0.33.1",
"trpc-svelte-query": "2.0.5",
"zod": "3.22.4"
"lodash": "4.17.21"
},
"devDependencies": {
"@prisma/client": "5.7.1",
"@sveltejs/kit": "2.0.6",
"@sveltejs/vite-plugin-svelte": "3.0.1",
"@types/cookie": "0.6.0",
"@types/lodash.kebabcase": "4.1.9",
"@types/lodash": "4.14.202",
"@types/node": "20.10.6",
"@vite-pwa/sveltekit": "0.3.0",
"autoprefixer": "10.4.16",
"bun-types": "1.0.21",
"daisyui": "4.5.0",
"postcss": "8.4.32",
"prettier": "3.1.1",
"prettier-plugin-svelte": "3.1.2",
"prettier-plugin-tailwindcss": "0.5.10",
"prisma": "5.7.1",
"rollup-plugin-visualizer": "5.12.0",
"svelte": "4.2.8",
"svelte-adapter-bun": "0.5.1",
"svelte-check": "3.6.2",
"tailwindcss": "3.4.0",
"tslib": "2.6.2",
"typescript": "5.3.3",
"vite": "5.0.10",
"vite-plugin-pwa": "0.17.4",
"workbox-window": "7.0.0"
},
"overrides": {
"@rollup/plugin-node-resolve": "15.2.3",
"sharp": "0.33.1"
"typescript": "5.3.3"
}
}
}
7 changes: 0 additions & 7 deletions prisma/migrations/20220830171401_initial_c/migration.sql

This file was deleted.

3 changes: 0 additions & 3 deletions prisma/migrations/migration_lock.toml

This file was deleted.

17 changes: 0 additions & 17 deletions prisma/schema.prisma

This file was deleted.

30 changes: 30 additions & 0 deletions scraper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@riffyh/scraper",
"version": "1.0.2",
"bin": "dist/index.js",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rayriffy/rayriffy-h.git"
},
"scripts": {
"build": "bun build src/index.ts --outfile dist/index.js --target bun -e kysely -e pg -e p-queue -e yargs"
},
"files": [
"dist"
],
"dependencies": {
"kysely": "0.27.2",
"pg": "8.11.3",
"p-queue": "8.0.1",
"yargs": "17.7.2"
},
"devDependencies": {
"@riffyh/commons": "workspace:*",
"@types/pg": "8.11.0",
"@types/yargs": "17.0.32"
}
}
8 changes: 8 additions & 0 deletions scraper/src/@types/SQLDatabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Hentai } from "@riffyh/commons"

export interface SQLDatabase {
Hentai: {
id: number
data: string
}
}
Loading

0 comments on commit 84f23f1

Please sign in to comment.