chore(project) cleanup
This commit is contained in:
149
.gitignore
vendored
149
.gitignore
vendored
@@ -1,27 +1,134 @@
|
||||
# dependencies
|
||||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||
# Logs
|
||||
logs
|
||||
_.log
|
||||
npm-debug.log_
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
_.pid
|
||||
_.seed
|
||||
\*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
\*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
|
||||
# bun
|
||||
bun.lockb
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# environments
|
||||
*.env
|
||||
*.env.*
|
||||
!.env.example
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# logs
|
||||
*.log
|
||||
# Optional REPL history
|
||||
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
|
||||
\*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
|
||||
.next
|
||||
out
|
||||
|
||||
# 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
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.\*
|
||||
|
||||
# system files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# builds
|
||||
dist/
|
||||
build/
|
||||
|
||||
# ides
|
||||
.idea/
|
||||
.vscode/
|
||||
*.sublime-workspace
|
||||
*.sublime-project
|
||||
|
||||
24
.npmignore
24
.npmignore
@@ -1,24 +0,0 @@
|
||||
# docs
|
||||
docs/
|
||||
|
||||
# web
|
||||
website/
|
||||
|
||||
# examples
|
||||
examples/
|
||||
|
||||
# test
|
||||
tests/
|
||||
|
||||
# dev
|
||||
node_modules/
|
||||
*.log
|
||||
*.env
|
||||
*.bun
|
||||
|
||||
# system
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# bun
|
||||
bun.lockb
|
||||
9
LICENSE
9
LICENSE
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Benjamin Wegener <contact@benni.fyi>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
14
README.md
14
README.md
@@ -1,5 +1,15 @@
|
||||
# layc
|
||||
|
||||
> simplified node/bun web framework
|
||||
To install dependencies:
|
||||
|
||||
**just imagine this**: you're building a web... okay, maybe don't.
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
To run:
|
||||
|
||||
```bash
|
||||
bun run lib/index.js
|
||||
```
|
||||
|
||||
This project was created using `bun init` in bun v1.0.0. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { LayServer } from '../src';
|
||||
import { LayServer } from '../lib';
|
||||
import { google } from 'googleapis';
|
||||
|
||||
class InfoController {
|
||||
static namespace = 'info';
|
||||
@@ -27,6 +28,44 @@ class InfoController {
|
||||
}
|
||||
}
|
||||
|
||||
class oAuthController {
|
||||
static namespace = 'oauth';
|
||||
constructor(server) {
|
||||
server.get('/:provider', this.auth.bind(this));
|
||||
server.get('/callback/:provider', this.callback.bind(this));
|
||||
}
|
||||
|
||||
async auth(req, res) {
|
||||
if (req.params.get('provider') != 'google') {
|
||||
return {
|
||||
messages: 'invalid provider',
|
||||
data: [...req.params.entries()],
|
||||
};
|
||||
}
|
||||
|
||||
const scopes = 'https://www.googleapis.com/auth/youtube';
|
||||
const url = oauth2Client.generateAuthUrl({
|
||||
// 'online' (default) or 'offline' (gets refresh_token)
|
||||
access_type: 'offline',
|
||||
|
||||
// If you only need one scope you can pass it as a string
|
||||
scope: scopes,
|
||||
});
|
||||
|
||||
console.log(url);
|
||||
|
||||
return Response.redirect(url, 301);
|
||||
}
|
||||
|
||||
callback(req, res) {
|
||||
if (!req.query.get('code')) {
|
||||
return new Response('/', { status: 302 });
|
||||
}
|
||||
|
||||
return new Response(`/${req.query.get('code')}`);
|
||||
}
|
||||
}
|
||||
|
||||
const server = new LayServer({
|
||||
controllers: [
|
||||
function Main(server) {
|
||||
@@ -71,8 +110,9 @@ const server = new LayServer({
|
||||
});
|
||||
});
|
||||
},
|
||||
oAuthController,
|
||||
InfoController,
|
||||
],
|
||||
});
|
||||
|
||||
server.listen(42069);
|
||||
server.listen(Bun.env.APP_PORT ?? Bun.env.PORT ?? 42169);
|
||||
|
||||
@@ -136,7 +136,7 @@ export default class LayServer {
|
||||
return await this.router.handle(req);
|
||||
}
|
||||
|
||||
listen(port = 3000) {
|
||||
listen(port = 8080) {
|
||||
try {
|
||||
this.proc = Bun.serve({
|
||||
port,
|
||||
26
package.json
26
package.json
@@ -1,11 +1,19 @@
|
||||
{
|
||||
"name": "layc",
|
||||
"version": "1.0.0",
|
||||
"main": "lib/layc.cjs",
|
||||
"module": "lib/layc.js",
|
||||
"scripts": {
|
||||
"test": "bun test",
|
||||
"examples": "bun run ./examples/index.js"
|
||||
},
|
||||
"type": "module"
|
||||
"name": "layc",
|
||||
"version": "1.0.0",
|
||||
"main": "lib/layc.cjs.js",
|
||||
"module": "lib/layc.js",
|
||||
"devDependencies": {
|
||||
"bun-types": "latest",
|
||||
"chokidar": "^3.5.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "bun test",
|
||||
"examples": "bun run ./examples/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@googleapis/youtube": "^12.0.0",
|
||||
"googleapis": "^127.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user