Skip to content

Commit bd50679

Browse files
環境構築手順書を作成する #35
1 parent 6a15279 commit bd50679

File tree

2 files changed

+81
-23
lines changed

2 files changed

+81
-23
lines changed

.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
55
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
66

7-
DATABASE_URL="mysql://johndoe:randompassword@localhost:3306/mydb"
7+
DATABASE_URL="mysql://user:password@localhost:3306/sveltekit_authentication"
88

9-
GMAIL_USER="iam.o.sin@gmail.com"
9+
GMAIL_USER="username@gmail.com"
1010
GMAIL_PASS="google_app_password"
1111

12-
TWITTER_CLIENT_ID=""
13-
TWITTER_CLIENT_SECRET=""
12+
TWITTER_CLIENT_ID="(option)"
13+
TWITTER_CLIENT_SECRET="(option)"

README.md

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,96 @@
1-
# create-svelte
1+
# SvelteKit Authentication Example
22

3-
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
3+
This is an example of how tow to sign up, sing in, authenticate, send PIN code mai, sign in with Google and sign in with Twitter.
44

5-
## Creating a project
5+
## Sign up
66

7-
If you're seeing this, you've probably already done this step. Congrats!
7+
This project does not have a sign up process. If the account does not exist in the database when you sign in, it will be created automatically.
8+
9+
## Sign in
10+
11+
You can sign in with only your email address and PIN code. To confirm your email address, this project will email you a PIN code.
12+
You can also sign in with Google and sign in with Twitter.
13+
14+
1. Local accounts via email
15+
2. Sign in with Google
16+
3. Sign in with Twitter
17+
18+
## Prerequisites
19+
20+
- [MySQL Community Server 8.0.30](https://dev.mysql.com/downloads/mysql/) or higher
21+
- [Node.js](https://nodejs.org/) 18.4.0 or higher
22+
- npm 8.13.2 or higher
23+
- Gmail account for sendmail
24+
25+
### Prerequisites for signing in with Google (option)
26+
27+
- [Google API client ID and setup](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid)
28+
29+
### Prerequisites for signing in with Twitter (option)
30+
31+
- [Twitter developer account and setup](https://developer.twitter.com/en/docs/apps/overview)
32+
33+
## Setting up the Gmail for sending PIN code emails
34+
35+
1. Visit [Google Account - Security](https://myaccount.google.com/security)
36+
1. Turn on 2-Step Verification
37+
1. Create an app password
38+
39+
## Setting up the project
40+
41+
Here are the steps:
42+
43+
1. Get the project and setup:
844

945
```bash
10-
# create a new project in the current directory
11-
npm create svelte@latest
46+
# Clone the repo to your current directory
47+
git clone https://github.com/sinProject-Inc/sveltekit_authentication_example.git
1248

13-
# create a new project in my-app
14-
npm create svelte@latest my-app
49+
# Install the dependencies
50+
cd /sveltekit_authentication_example
51+
npm install
1552
```
1653

17-
## Developing
54+
2. Create a database named sveltekit_authentication
55+
3. Create a .env file by copying .env.example at the top level of the project
56+
4. rewrite the env file:
1857

19-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
58+
```env
59+
DATABASE_URL="mysql://user:password@localhost:3306/sveltekit_authentication"
2060
21-
```bash
22-
npm run dev
61+
GMAIL_USER="username@gmail.com"
62+
GMAIL_PASS="google_app_password"
2363
24-
# or start the server and open the app in a new browser tab
25-
npm run dev -- --open
64+
TWITTER_CLIENT_ID="(option)"
65+
TWITTER_CLIENT_SECRET="(option)"
2666
```
2767

28-
## Building
68+
5. Push the initial schema to the database:
69+
70+
```bash
71+
npx prisma db push
72+
```
2973

30-
To create a production version of your app:
74+
## Run locally
3175

3276
```bash
33-
npm run build
77+
# Start the server and open the app in a new browser tab
78+
npm run dev -- --open
3479
```
3580

36-
You can preview the production build with `npm run preview`.
81+
## Set initial data only for the first time
82+
83+
Write Roles and Lifetime settings:
84+
85+
visit http://localhost:5173/initialize_database
86+
87+
## How to sign in
88+
89+
1. visit sign in page
90+
2. Enter your email address
91+
3. Check your email for PIN code
92+
4. Enter PIN code
93+
94+
## My ask of you
3795

38-
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
96+
Please report any issues [here](https://github.com/sinProject-Inc/sveltekit_authentication_example/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc). [Pull requests](https://github.com/sinProject-Inc/sveltekit_authentication_example/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) are encouraged especially as SvelteKit is evolving rapidly.

0 commit comments

Comments
 (0)