Skip to content

Commit

Permalink
Merge pull request #2 from SivaramPg/swapi-reborn
Browse files Browse the repository at this point in the history
V2: Swapi Reborn
  • Loading branch information
SivaramPg authored Aug 25, 2024
2 parents 9ac3b4c + 8a34475 commit 5792201
Show file tree
Hide file tree
Showing 338 changed files with 12,318 additions and 14,133 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
NODE_VERSION=18
YARN_VERSION=1
NODE_VERSION=20
BUN_VERSION=1.1.5

DOMAIN_BASE_URL=
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

Binary file added .github/swapi-info.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/swapi-info.png
Binary file not shown.
18 changes: 18 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Code quality

on:
push:
pull_request:

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci .
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts


.env*
!.env.example
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bunx lint-staged
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src
public

**/*
7 changes: 7 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:80 {
log {
format console
}

file_server
}
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM oven/bun:1.1.5-alpine AS base

# Install dependencies only when needed
FROM base AS deps
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json bun.lockb ./
RUN bun install --ignore-scripts


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN bun run --bun build

# Production image, copy all the files and run next
FROM caddy:2.4.5-alpine AS runner

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY Caddyfile /etc/caddy/Caddyfile
COPY --from=builder --chown=nextjs:nodejs /app/out /srv/

USER nextjs

EXPOSE 80

CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SWAPI.INFO is an Open Source no-server, file-based simple GET API provider & end
<!-- ![SWAPI.INFO](https://swapi.info/opengraph-image.png) -->

<div align="center">
<img src=".github/swapi-info.png">
<img src=".github/swapi-info.jpg">
</div>

### [Health Status](https://status.swapi.info/)
Expand Down
35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"ignoreUnknown": true
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineWidth": 80,
"lineEnding": "lf",
"ignore": []
},
"javascript": {
"formatter": {
"arrowParentheses": "always",
"jsxQuoteStyle": "double",
"semicolons": "asNeeded",
"trailingComma": "all",
"quoteProperties": "asNeeded",
"bracketSpacing": true,
"bracketSameLine": false
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
Binary file added bun.lockb
Binary file not shown.
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
swapi.info:
ports:
- 3000:3000
build:
context: .
dockerfile: Dockerfile
26 changes: 21 additions & 5 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: 'https://swapi.info',
output: 'export',
generateIndexSitemap: false,
exclude: '/api*',
const sitemapConfig = {
siteUrl: "https://swapi.info",
output: "export",
generateIndexSitemap: false,
exclude: [
"/api/*",
"/films",
"/films/*",
"/people",
"/people/*",
"/planets",
"/planets/*",
"/species",
"/species/*",
"/starships",
"/starships/*",
"/vehicles",
"/vehicles/*",
],
}

module.exports = sitemapConfig
4 changes: 2 additions & 2 deletions next.config.js → next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
output: "export",
}

module.exports = nextConfig
export default nextConfig
70 changes: 42 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
{
"name": "sw-api",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postbuild": "next-sitemap"
},
"dependencies": {
"@types/node": "20.11.25",
"@types/react": "18.2.64",
"@types/react-dom": "18.2.21",
"autoprefixer": "10.4.18",
"bright": "^0.8.4",
"clsx": "^2.0.0",
"eslint": "8.57.0",
"eslint-config-next": "14.1.3",
"next": "14.1.3",
"next-sitemap": "^4.1.8",
"postcss": "8.4.35",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.4.1",
"typescript": "5.4.2",
"use-clipboard-copy": "^0.2.0"
}
"name": "swapi-reborn",
"version": "2.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"postbuild": "next-sitemap",
"prepare": "husky"
},
"dependencies": {
"bright": "^0.8.5",
"clsx": "^2.0.0",
"next": "14.2.3",
"next-sitemap": "^4.2.3",
"next-themes": "^0.3.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"tailwind-merge": "^2.3.0",
"use-clipboard-copy": "^0.2.0",
"zod": "^3.23.5"
},
"devDependencies": {
"@biomejs/biome": "^1.6.2",
"@types/bun": "^1.1.1",
"@types/node": "20.11.25",
"@types/react": "18.2.64",
"@types/react-dom": "18.2.21",
"autoprefixer": "10.4.18",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"postcss": "8.4.35",
"tailwindcss": "3.4.1",
"typescript": "5.4.2"
},
"lint-staged": {
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
"biome check --apply --no-errors-on-unmatched",
"biome format --write --no-errors-on-unmatched",
"biome lint --apply --no-errors-on-unmatched"
]
}
}
8 changes: 4 additions & 4 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
114 changes: 57 additions & 57 deletions public/api/films/1.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
{
"title": "A New Hope",
"episode_id": 4,
"opening_crawl": "It is a period of civil war.\r\nRebel spaceships, striking\r\nfrom a hidden base, have won\r\ntheir first victory against\r\nthe evil Galactic Empire.\r\n\r\nDuring the battle, Rebel\r\nspies managed to steal secret\r\nplans to the Empire's\r\nultimate weapon, the DEATH\r\nSTAR, an armored space\r\nstation with enough power\r\nto destroy an entire planet.\r\n\r\nPursued by the Empire's\r\nsinister agents, Princess\r\nLeia races home aboard her\r\nstarship, custodian of the\r\nstolen plans that can save her\r\npeople and restore\r\nfreedom to the galaxy....",
"director": "George Lucas",
"producer": "Gary Kurtz, Rick McCallum",
"release_date": "1977-05-25",
"characters": [
"https://swapi.info/api/people/1",
"https://swapi.info/api/people/2",
"https://swapi.info/api/people/3",
"https://swapi.info/api/people/4",
"https://swapi.info/api/people/5",
"https://swapi.info/api/people/6",
"https://swapi.info/api/people/7",
"https://swapi.info/api/people/8",
"https://swapi.info/api/people/9",
"https://swapi.info/api/people/10",
"https://swapi.info/api/people/12",
"https://swapi.info/api/people/13",
"https://swapi.info/api/people/14",
"https://swapi.info/api/people/15",
"https://swapi.info/api/people/16",
"https://swapi.info/api/people/18",
"https://swapi.info/api/people/19",
"https://swapi.info/api/people/81"
],
"planets": [
"https://swapi.info/api/planets/1",
"https://swapi.info/api/planets/2",
"https://swapi.info/api/planets/3"
],
"starships": [
"https://swapi.info/api/starships/2",
"https://swapi.info/api/starships/3",
"https://swapi.info/api/starships/5",
"https://swapi.info/api/starships/9",
"https://swapi.info/api/starships/10",
"https://swapi.info/api/starships/11",
"https://swapi.info/api/starships/12",
"https://swapi.info/api/starships/13"
],
"vehicles": [
"https://swapi.info/api/vehicles/4",
"https://swapi.info/api/vehicles/6",
"https://swapi.info/api/vehicles/7",
"https://swapi.info/api/vehicles/8"
],
"species": [
"https://swapi.info/api/species/1",
"https://swapi.info/api/species/2",
"https://swapi.info/api/species/3",
"https://swapi.info/api/species/4",
"https://swapi.info/api/species/5"
],
"created": "2014-12-10T14:23:31.880000Z",
"edited": "2014-12-20T19:49:45.256000Z",
"url": "https://swapi.info/api/films/1"
"title": "A New Hope",
"episode_id": 4,
"opening_crawl": "It is a period of civil war.\r\nRebel spaceships, striking\r\nfrom a hidden base, have won\r\ntheir first victory against\r\nthe evil Galactic Empire.\r\n\r\nDuring the battle, Rebel\r\nspies managed to steal secret\r\nplans to the Empire's\r\nultimate weapon, the DEATH\r\nSTAR, an armored space\r\nstation with enough power\r\nto destroy an entire planet.\r\n\r\nPursued by the Empire's\r\nsinister agents, Princess\r\nLeia races home aboard her\r\nstarship, custodian of the\r\nstolen plans that can save her\r\npeople and restore\r\nfreedom to the galaxy....",
"director": "George Lucas",
"producer": "Gary Kurtz, Rick McCallum",
"release_date": "1977-05-25",
"characters": [
"https://swapi.info/api/people/1",
"https://swapi.info/api/people/2",
"https://swapi.info/api/people/3",
"https://swapi.info/api/people/4",
"https://swapi.info/api/people/5",
"https://swapi.info/api/people/6",
"https://swapi.info/api/people/7",
"https://swapi.info/api/people/8",
"https://swapi.info/api/people/9",
"https://swapi.info/api/people/10",
"https://swapi.info/api/people/12",
"https://swapi.info/api/people/13",
"https://swapi.info/api/people/14",
"https://swapi.info/api/people/15",
"https://swapi.info/api/people/16",
"https://swapi.info/api/people/18",
"https://swapi.info/api/people/19",
"https://swapi.info/api/people/81"
],
"planets": [
"https://swapi.info/api/planets/1",
"https://swapi.info/api/planets/2",
"https://swapi.info/api/planets/3"
],
"starships": [
"https://swapi.info/api/starships/2",
"https://swapi.info/api/starships/3",
"https://swapi.info/api/starships/5",
"https://swapi.info/api/starships/9",
"https://swapi.info/api/starships/10",
"https://swapi.info/api/starships/11",
"https://swapi.info/api/starships/12",
"https://swapi.info/api/starships/13"
],
"vehicles": [
"https://swapi.info/api/vehicles/4",
"https://swapi.info/api/vehicles/6",
"https://swapi.info/api/vehicles/7",
"https://swapi.info/api/vehicles/8"
],
"species": [
"https://swapi.info/api/species/1",
"https://swapi.info/api/species/2",
"https://swapi.info/api/species/3",
"https://swapi.info/api/species/4",
"https://swapi.info/api/species/5"
],
"created": "2014-12-10T14:23:31.880000Z",
"edited": "2014-12-20T19:49:45.256000Z",
"url": "https://swapi.info/api/films/1"
}
Loading

0 comments on commit 5792201

Please sign in to comment.