sveltekit-auth-example 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore CHANGED
@@ -1,5 +1,6 @@
1
1
  .DS_Store
2
2
  node_modules
3
+ .yarn
3
4
  /build
4
5
  /.svelte-kit
5
6
  /package
@@ -0,0 +1,7 @@
1
+ {
2
+ "prettier.configPath": "prettier.config.mjs",
3
+ "prettier.ignorePath": ".eslintignore",
4
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
5
+ "eslint.debug": false,
6
+ "eslint.experimental.useFlatConfig": true
7
+ }
package/CHANGELOG.md CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  - Add password complexity checking on /register and /profile pages (only checks for length currently despite what the pages say)
4
4
 
5
+ # 2.0.3
6
+ - Move to eslint's new eslint.config.js
7
+ - Convert vite.config to TypeScript
8
+
5
9
  # 2.0.2
6
- - fix prettier
10
+
11
+ - Fix prettier
7
12
 
8
13
  # 2.0.1
9
14
 
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  root: true,
3
3
  parser: '@typescript-eslint/parser',
4
4
  extends: [
@@ -9,7 +9,6 @@ module.exports = {
9
9
  ],
10
10
  plugins: ['@typescript-eslint'],
11
11
  ignorePatterns: ['*.cjs'],
12
- overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
13
12
  parserOptions: {
14
13
  sourceType: 'module',
15
14
  ecmaVersion: 2020,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sveltekit-auth-example",
3
3
  "description": "SvelteKit Authentication Example",
4
- "version": "2.0.2",
4
+ "version": "2.0.3",
5
5
  "author": "Nate Stuyvesant",
6
6
  "license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
7
7
  "repository": {
@@ -27,8 +27,8 @@
27
27
  "preview": "vite preview",
28
28
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
29
29
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
30
- "lint": "prettier --check . && eslint .",
31
- "format": "prettier --write ."
30
+ "lint": "prettier --check . && eslint . --ignore-path ./.eslintignore",
31
+ "format": "prettier --write . --ignore-path ./.eslintignore"
32
32
  },
33
33
  "engines": {
34
34
  "node": "^18.19.0"
@@ -1,7 +1,9 @@
1
1
  export default {
2
2
  $schema: 'https://json.schemastore.org/prettierrc',
3
3
  useTabs: true,
4
+ tabWidth: 2,
4
5
  semi: false,
6
+ arrowParens: 'avoid',
5
7
  singleQuote: true,
6
8
  trailingComma: 'none',
7
9
  printWidth: 100,
package/src/lib/google.ts CHANGED
@@ -17,7 +17,7 @@ export function renderGoogleButton() {
17
17
 
18
18
  export function initializeGoogleAccounts() {
19
19
  let initialized = false
20
- const unsubscribe = googleInitialized.subscribe((value) => {
20
+ const unsubscribe = googleInitialized.subscribe(value => {
21
21
  initialized = value
22
22
  })
23
23
 
@@ -46,7 +46,7 @@ export function initializeGoogleAccounts() {
46
46
  const { role } = fromEndpoint.user
47
47
 
48
48
  let referrer
49
- const unsubscribe = page.subscribe((p) => {
49
+ const unsubscribe = page.subscribe(p => {
50
50
  referrer = p.url.searchParams.get('referrer')
51
51
  })
52
52
  unsubscribe()
@@ -2,7 +2,7 @@ import { error, json } from '@sveltejs/kit'
2
2
  import type { RequestHandler } from './$types'
3
3
  import { query } from '$lib/server/db'
4
4
 
5
- export const PUT: RequestHandler = async (event) => {
5
+ export const PUT: RequestHandler = async event => {
6
6
  const { user } = event.locals
7
7
 
8
8
  if (!user) error(401, 'Unauthorized - must be logged-in.')
@@ -2,7 +2,7 @@ import { error, json } from '@sveltejs/kit'
2
2
  import type { RequestHandler } from './$types'
3
3
  import { query } from '$lib/server/db'
4
4
 
5
- export const POST: RequestHandler = async (event) => {
5
+ export const POST: RequestHandler = async event => {
6
6
  const { cookies } = event
7
7
  const { slug } = event.params
8
8
 
@@ -6,7 +6,7 @@ import { JWT_SECRET, DOMAIN, SENDGRID_SENDER } from '$env/static/private'
6
6
  import { query } from '$lib/server/db'
7
7
  import { sendMessage } from '$lib/server/sendgrid'
8
8
 
9
- export const POST: RequestHandler = async (event) => {
9
+ export const POST: RequestHandler = async event => {
10
10
  const body = await event.request.json()
11
11
  const sql = `SELECT id as "userId" FROM users WHERE email = $1 LIMIT 1;`
12
12
  const { rows } = await query(sql, [body.email])
@@ -41,7 +41,7 @@ async function upsertGoogleUser(user: Partial<User>): Promise<UserSession> {
41
41
  }
42
42
 
43
43
  // Returns local user if Google user authenticated (and authorized our app)
44
- export const POST: RequestHandler = async (event) => {
44
+ export const POST: RequestHandler = async event => {
45
45
  const { cookies } = event
46
46
 
47
47
  try {
@@ -5,7 +5,7 @@ import jwt from 'jsonwebtoken'
5
5
  import { JWT_SECRET } from '$env/static/private'
6
6
  import { query } from '$lib/server/db'
7
7
 
8
- export const PUT: RequestHandler = async (event) => {
8
+ export const PUT: RequestHandler = async event => {
9
9
  const body = await event.request.json()
10
10
  const { token, password } = body
11
11
 
@@ -1,6 +1,6 @@
1
1
  import type { PageLoad } from './$types'
2
2
 
3
- export const load: PageLoad = async (event) => {
3
+ export const load: PageLoad = async event => {
4
4
  return {
5
5
  token: event.params.token
6
6
  }
@@ -15,7 +15,7 @@ const ASSETS = [
15
15
  ...files // everything in `static`
16
16
  ]
17
17
 
18
- sw.addEventListener('install', (event) => {
18
+ sw.addEventListener('install', event => {
19
19
  // Create a new cache and add all files to it
20
20
  async function addFilesToCache() {
21
21
  const cache = await caches.open(CACHE)
@@ -25,7 +25,7 @@ sw.addEventListener('install', (event) => {
25
25
  event.waitUntil(addFilesToCache())
26
26
  })
27
27
 
28
- sw.addEventListener('activate', (event) => {
28
+ sw.addEventListener('activate', event => {
29
29
  // Remove previous cached data from disk
30
30
  async function deleteOldCaches() {
31
31
  for (const key of await caches.keys()) {
@@ -36,7 +36,7 @@ sw.addEventListener('activate', (event) => {
36
36
  event.waitUntil(deleteOldCaches())
37
37
  })
38
38
 
39
- sw.addEventListener('fetch', (event) => {
39
+ sw.addEventListener('fetch', event => {
40
40
  // ignore POST requests etc
41
41
  if (event.request.method !== 'GET') return
42
42
 
package/vite.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { sveltekit } from '@sveltejs/kit/vite'
2
+ import { defineConfig } from 'vite'
3
+
4
+ export default defineConfig({
5
+ plugins: [sveltekit()],
6
+ server: {
7
+ host: 'localhost',
8
+ port: 3000,
9
+ open: 'http://localhost:3000'
10
+ }
11
+ })
package/.prettierignore DELETED
@@ -1,14 +0,0 @@
1
- .DS_Store
2
- node_modules
3
- .yarn
4
- /build
5
- /.svelte-kit
6
- /package
7
- .env
8
- .env.*
9
- !.env.example
10
-
11
- # Ignore files for PNPM, NPM and YARN
12
- pnpm-lock.yaml
13
- package-lock.json
14
- yarn.lock
package/vite.config.js DELETED
@@ -1,16 +0,0 @@
1
- import { sveltekit } from '@sveltejs/kit/vite'
2
-
3
- /** @type {import('vite').UserConfig} */
4
- const config = {
5
- plugins: [sveltekit()],
6
- serviceWorker: {
7
- files: (filepath) => !/\.DS_Store/.test(filepath)
8
- },
9
- server: {
10
- host: 'localhost',
11
- port: 3000,
12
- open: 'http://localhost:3000'
13
- }
14
- }
15
-
16
- export default config