Skip to content

Commit

Permalink
chore(app): first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
razshare committed Apr 1, 2024
1 parent ef3bd76 commit 1275c16
Show file tree
Hide file tree
Showing 28 changed files with 724 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
/src/app.html

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
55 changes: 55 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @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: 2024,
extraFileExtensions: ['.svelte'],
},
env: {
browser: true,
es2017: true,
node: true,
},
globals: {
Bun: 'readonly',
},
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'func-names': ['error', 'always'],
/**
* Remember to set "eslint.validate": ["javascript", "svelte"] in settings.json.
*/
// @see https://astexplorer.net/
'no-restricted-syntax': [
'error',
{
selector: 'ArrowFunctionExpression',
message: 'Shorthand arrow functions are not allowed.',
},
{
selector: 'ClassDeclaration',
message: 'Classes are not allowed, use object literals instead.',
},
],
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
},
},
],
}
37 changes: 37 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm i
- run: npm run lint:fix
- run: npm run build

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm i
- run: npm run lint:fix
- run: npm run build
- run: npm run package
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
node_modules
/build
/dist
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions .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
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"arrowParens": "avoid",
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80,
"plugins": ["prettier-plugin-svelte"],
"semi": false,
"svelteSortOrder": "options-styles-scripts-markup",
"svelteStrictMode": false,
"svelteBracketNewLine": true,
"svelteIndentScriptAndStyle": true,
"useTabs": false,
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"bracketSpacing": true,
"quoteProps": "consistent"
}
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "launch",
"name": "Debug File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"watchMode": false
},
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "launch",
"name": "Run File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"noDebug": true,
"watchMode": false
},
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "attach",
"name": "Attach Bun",
"url": "ws://localhost:6499/",
"stopOnEntry": false
}
]
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Razvan
Copyright (c) 2023 Razvan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SvelteKit Session

This library provides an easy way to create and read sessions on the server.

Install with:

```sh
npm i -D sveltekit-session
```
Binary file added bun.lockb
Binary file not shown.
20 changes: 20 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"types": ["bun-types"],
"isolatedModules": true,
"lib": ["esnext", "DOM", "DOM.Iterable"],
"moduleResolution": "node",
"module": "esnext",
"target": "esnext",
"ignoreDeprecations": "5.0",
},
}
59 changes: 59 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "sveltekit-session",
"version": "0.1.0",
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
"preview": "vite preview",
"package": "svelte-kit sync && svelte-package && publint",
"prepublishOnly": "npm run package",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"lint:fix": "eslint --no-error-on-unmatched-pattern --fix \"./src/**/*.{js,ts,html,svelte}\"",
"format": "prettier --write ."
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"svelte": "./dist/index.js"
}
},
"files": [
"dist",
"!dist/**/*.test.*",
"!dist/**/*.spec.*"
],
"peerDependencies": {
"@microsoft/fetch-event-source": "^2.0.1",
"@sveltejs/kit": "^1.25.2 || ^2.0.0",
"svelte": "^4.0.0"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-node": "^5.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/package": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "8.56.0",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"bun-types": "latest",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"install": "^0.13.0",
"npm": "^10.2.5",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"publint": "^0.1.9",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.11"
},
"svelte": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module"
}
13 changes: 13 additions & 0 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}

export {}
12 changes: 12 additions & 0 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html/>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div>%sveltekit.body%</div>
</body>
</html>
1 change: 1 addition & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const IS_BROWSER = typeof document !== 'undefined'
13 changes: 13 additions & 0 deletions src/lib/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @template [T=void]
* @param {string|Error|unknown} value
* @returns {import("./types").Unsafe<T>}
*/
export function error(value) {
if (value instanceof Error) {
// @ts-ignore
return { value: null, error: value }
}
// @ts-ignore
return { value: null, error: new Error(`${value}`) }
}
4 changes: 4 additions & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { source } from './source.js'
import { events } from './events.js'
export * from './types.js'
export { source, events }
9 changes: 9 additions & 0 deletions src/lib/ok.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @template [T=void]
* @param {T} [value]
* @returns {import("./types").Unsafe<T>}
*/
export function ok(value) {
// @ts-ignore
return { value, error: false }
}
Loading

0 comments on commit 1275c16

Please sign in to comment.