Skip to content

Commit

Permalink
chore: init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
gxmari007 committed Jan 4, 2024
0 parents commit 0c21a17
Show file tree
Hide file tree
Showing 42 changed files with 10,807 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": ["@roshan-labs/eslint-config"]
}
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Dependencies
node_modules

# Logs
*.log*

# Temp directories
.temp
.tmp
.cache

# Yarn
**/.yarn/cache
**/.yarn/*state*

# Generated dirs
dist

# Nuxt
.nuxt
.output
.data
.vercel_build_output
.build-*
.netlify

# Env
.env

# Testing
reports
coverage
*.lcov
.nyc_output

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Intellij idea
*.iml
.idea

# OSX
.DS_Store
.AppleDouble
.LSOverride
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 100
}
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!--
Get your module up and running quickly.
Find and replace all on all files (CMD+SHIFT+F):
- Name: My Module
- Package name: my-module
- Description: My new Nuxt module
-->

# @roshan-labs/auth

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href]

My new Nuxt module for doing amazing things.

- [&nbsp;Release Notes](/CHANGELOG.md)
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
<!-- - [📖 &nbsp;Documentation](https://example.com) -->

## Features

<!-- Highlight some of the features your module provide here -->
-&nbsp;Foo
- 🚠 &nbsp;Bar
- 🌲 &nbsp;Baz

## Quick Setup

1. Add `my-module` dependency to your project

```bash
# Using pnpm
pnpm add -D my-module

# Using yarn
yarn add --dev my-module

# Using npm
npm install --save-dev my-module
```

2. Add `my-module` to the `modules` section of `nuxt.config.ts`

```js
export default defineNuxtConfig({
modules: [
'my-module'
]
})
```

That's it! You can now use My Module in your Nuxt app ✨

## Development

```bash
# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release
```

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/my-module

[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/my-module

[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/my-module

[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com
58 changes: 58 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@roshan-labs/auth",
"description": "My new Nuxt module",
"repository": "your-org/my-module",
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/types.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist"
],
"scripts": {
"prepack": "nuxt-module-build build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground && nuxi prepare playground-refresh",
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
"lint": "eslint .",
"test": "vitest run",
"test:watch": "vitest watch"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"@nuxt/kit": "^3.8.2",
"@roshan-labs/http": "^0.0.3",
"defu": "^6.1.3",
"knitwork": "^1.0.0",
"ufo": "^1.3.2"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@nuxt/module-builder": "^0.5.4",
"@nuxt/schema": "^3.8.2",
"@nuxt/test-utils": "^3.9.0",
"@roshan-labs/eslint-config": "^1.4.0",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.10.3",
"changelogen": "^0.5.5",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.56.0",
"jsonwebtoken": "^9.0.2",
"nuxt": "^3.8.2",
"ts-essentials": "^9.4.1",
"vitest": "^1.1.0",
"zod": "^3.22.4"
}
}
3 changes: 3 additions & 0 deletions playground-refresh/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<nuxt-page></nuxt-page>
</template>
4 changes: 4 additions & 0 deletions playground-refresh/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['../src/module'],
})
13 changes: 13 additions & 0 deletions playground-refresh/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "playground-refresh",
"private": true,
"type": "module",
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"generate": "nuxi generate"
},
"devDependencies": {
"nuxt": "latest"
}
}
3 changes: 3 additions & 0 deletions playground-refresh/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
3 changes: 3 additions & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<nuxt-page></nuxt-page>
</template>
26 changes: 26 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default defineNuxtConfig({
modules: ['../src/module'],
devtools: { enabled: true },
build: {
transpile: ['jsonwebtoken'],
},
auth: {
baseURL: '/api/auth',
provider: {
type: 'local',
endpoints: {
signIn: { path: '/login', method: 'post' },
signOut: false,
getSession: { path: '/user', method: 'get' },
},
pages: {
login: '/login',
},
permission: {
isEnabled: true,
permissionPointer: '/permission',
},
},
globalAppMiddleware: true,
},
})
13 changes: 13 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "playground-local",
"private": true,
"type": "module",
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"generate": "nuxi generate"
},
"devDependencies": {
"nuxt": "latest"
}
}
17 changes: 17 additions & 0 deletions playground/pages/about.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<h1>About</h1>
<div>
<button @click="() => signOut({ redirect: true })">Sign out</button>
</div>
</div>
</template>

<script lang="ts" setup>
definePageMeta({
auth: {
permission: 'page',
},
})
const { signOut } = useAuth()
</script>
27 changes: 27 additions & 0 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div>
<h1>Home</h1>
<div>
<div>
<nuxt-link to="/about">About</nuxt-link>
</div>
<div>
<button @click="logout">Sign Out</button>
</div>
<div>
<button>Add</button>
<button v-permission="['edit']">Edit</button>
<button v-permission="['add', 'delete']">Delete</button>
<button v-permission="['no-permissions']">Can't see me</button>
</div>
</div>
</div>
</template>

<script lang="ts" setup>
const { signOut } = useAuth()
const logout = () => {
signOut()
}
</script>
28 changes: 28 additions & 0 deletions playground/pages/login.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<div>
<h1>Login</h1>
<form @submit.prevent="login">
<input v-model="username" type="text" placeholder="Username" />
<input v-model="password" type="password" placeholder="Password" />
<button type="submit">login</button>
</form>
</div>
</template>

<script lang="ts" setup>
definePageMeta({
auth: {
unauthenticatedOnly: true,
navigateAuthenticatedTo: '/',
},
})
const { signIn } = useAuth()
const username = ref('')
const password = ref('')
const login = () => {
signIn({ username: username.value, password: password.value })
}
</script>
Loading

0 comments on commit 0c21a17

Please sign in to comment.