Skip to content

Commit

Permalink
nextjs 기반으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hmu332233 committed Mar 11, 2022
1 parent c072e8e commit 11f1a05
Show file tree
Hide file tree
Showing 23 changed files with 2,028 additions and 353 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
122 changes: 28 additions & 94 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,38 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Runtime data
pids
*.pid
*.seed
*.pid.lock
# dependencies
/node_modules
/.pnp
.pnp.js

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# testing
/coverage

# Coverage directory used by tools like istanbul
coverage
*.lcov
# next.js
/.next/
/out/

# nyc test coverage
.nyc_output
# production
/build

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# misc
.DS_Store
*.pem

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# Dependency directories
node_modules/
jspm_packages/
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# TypeScript v1 declaration files
typings/
# vercel
.vercel

# TypeScript cache
# typescript
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# svg.moon
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
16 changes: 0 additions & 16 deletions api/moon-preview.ts

This file was deleted.

23 changes: 0 additions & 23 deletions api/moon/[...params].ts

This file was deleted.

14 changes: 0 additions & 14 deletions api/moon/index.ts

This file was deleted.

5 changes: 5 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
6 changes: 6 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}

module.exports = nextConfig
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"name": "svg.moon",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/hmu332233/svg.moon.git",
"author": "minung.han <hmu332233@gmail.com>",
"license": "MIT",
"version": "0.1.0",
"private": true,
"scripts": {
"build:dev": "tsc -p tsconfig.json"
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@vercel/node": "^1.13.0",
"astronomy-bundle": "^7.5.3"
"astronomy-bundle": "^7.5.3",
"next": "12.1.0",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/node": "^17.0.21",
"typescript": "^4.6.2"
"@types/node": "17.0.21",
"@types/react": "17.0.40",
"eslint": "8.10.0",
"eslint-config-next": "12.1.0",
"typescript": "4.6.2"
}
}
8 changes: 8 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import '../styles/globals.css'
import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}

export default MyApp
26 changes: 26 additions & 0 deletions pages/api/moon/[...params].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const { params } = req.query;
const [day, month, year] = params as string[];

if (!year || !month || !day) {
return res.status(404).send('Not Found');
}

const date = `${year}-${month}-${day}`;

res.status(200).send(`
<html>
<head>
<title>Moon Phase (${date})</title>
<meta property="og:image" content="https://svg-moon.vercel.app/api/moon?date=${date}">
</head>
<body></body>
</html>
`);
}
25 changes: 25 additions & 0 deletions pages/api/moon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'

import { getMoonPhases } from '../../../server/utils/moon';
import { createMoon } from '../../../server/utils/svg';


export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const { date } = req.query;

const { k, isWaxing } = await getMoonPhases(date ? new Date(date as string) : undefined);
const moonSvg = createMoon(k, isWaxing);

res.statusCode = 200;
res.setHeader("Content-Type", "text/html; charset=utf-8");
// res.setHeader(
// "Cache-Control",
// "public, immutable, no-transform, s-maxage=31536000, max-age=31536000"
// );

res.end(moonSvg);
}
Loading

1 comment on commit 11f1a05

@vercel
Copy link

@vercel vercel bot commented on 11f1a05 Mar 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.