Skip to content

Commit c670228

Browse files
authored
Merge pull request #12 from zgid123/refactor/rework-project-to-typescript
rework project
2 parents 695bc28 + 83278b0 commit c670228

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6561
-4714
lines changed

.babelrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.d.ts

.eslintrc

Lines changed: 0 additions & 60 deletions
This file was deleted.

.eslintrc.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"es6": true,
5+
"node": true
6+
},
7+
"globals": {
8+
"models": true
9+
},
10+
"parser": "@typescript-eslint/parser",
11+
"plugins": [
12+
"@typescript-eslint"
13+
],
14+
"extends": [
15+
"eslint:recommended",
16+
"plugin:@typescript-eslint/eslint-recommended",
17+
"plugin:@typescript-eslint/recommended",
18+
"plugin:prettier/recommended"
19+
],
20+
"parserOptions": {
21+
"sourceType": "module",
22+
"ecmaVersion": 8,
23+
"ecmaFeatures": {
24+
"experimentalObjectRestSpread": true,
25+
"jsx": true
26+
}
27+
},
28+
"rules": {
29+
"@typescript-eslint/no-explicit-any": "off",
30+
"@typescript-eslint/semi": [
31+
"error",
32+
"always"
33+
],
34+
"@typescript-eslint/naming-convention": [
35+
"error"
36+
],
37+
"@typescript-eslint/explicit-function-return-type": "off",
38+
"@typescript-eslint/no-unused-vars": [
39+
"error",
40+
{
41+
"argsIgnorePattern": "^_"
42+
}
43+
],
44+
"comma-dangle": [
45+
"error",
46+
"always-multiline"
47+
],
48+
"linebreak-style": [
49+
"error",
50+
"unix"
51+
],
52+
"max-len": "off",
53+
"new-cap": "off",
54+
"no-console": "off",
55+
"object-curly-spacing": "off",
56+
"require-jsdoc": "off",
57+
"valid-jsdoc": "off",
58+
"quotes": [
59+
"error",
60+
"single"
61+
]
62+
}
63+
}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ reports/
44
.DS_Store
55

66
node_modules
7-
npm-debug.log
8-
yarn-error.log
97
lib
8+
dist
9+
10+
.env

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn lint-staged
4+
pnpm lint-staged

.npmignore

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
.husky
21
src
3-
test
4-
.babelrc
5-
.eslintrc
6-
.gitignore
7-
.lintstagedrc
8-
package.json
9-
README.md
2+
.eslintrc.json
103
tsconfig.json
11-
yarn.lock
4+
pnpm-lock.yaml
5+
pnpm-workspace.yaml
6+
.husky
7+
.lintstagedrc
8+
.prettierrc

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"jsxSingleQuote": true,
5+
"arrowParens": "always"
6+
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"typescript.preferences.importModuleSpecifier": "non-relative",
3+
"[typescript]": {
4+
"editor.defaultFormatter": "esbenp.prettier-vscode"
5+
},
6+
"files.eol": "\n"
7+
}

README.md

Lines changed: 3 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,5 @@
1-
# passport-google-oauth-token
1+
Passport's strategy for Javascript project.
22

3-
[Passport](http://passportjs.org/) strategy for authenticating with [Google](http://www.google.com/)
4-
access tokens using the OAuth 2.0 API.
3+
# Packages
54

6-
This module is created based on [passport-facebook-token](https://github.com/drudge/passport-facebook-token)
7-
and [passport-google-oauth2](https://github.com/jaredhanson/passport-google-oauth2).
8-
9-
This module lets you authenticate using Google in your Node.js applications.
10-
By plugging into Passport, Google authentication can be easily and
11-
unobtrusively integrated into any application or framework that supports
12-
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
13-
[Express](http://expressjs.com/).
14-
15-
## Installation
16-
17-
$ npm install passport-google-oauth-token
18-
19-
## Usage
20-
21-
### Configure Strategy
22-
23-
The Google authentication strategy authenticates users using a Google
24-
account and OAuth 2.0 tokens. The strategy requires a `verify` callback, which
25-
accepts these credentials and calls `cb` providing a user, as well as
26-
`options` specifying an app ID and app secret.
27-
28-
```js
29-
const GoogleOauthTokenStrategy = require('passport-google-oauth-token');
30-
31-
passport.use(new GoogleOauthTokenStrategy({
32-
clientID: GOOGLE_CLIENT_ID,
33-
clientSecret: GOOGLE_CLIENT_SECRET,
34-
}, (accessToken, refreshToken, profile, cb) => {
35-
User.findOrCreate({ googleId: profile.id }, (error, user) => {
36-
return done(error, user);
37-
});
38-
}));
39-
```
40-
41-
### Authenticate Requests
42-
43-
Use `passport.authenticate()`, specifying the `'google-oauth-token'` strategy, to authenticate requests.
44-
45-
```js
46-
app.post('/auth/google/token',
47-
passport.authenticate('google-oauth-token'),
48-
(req, res) => {
49-
// do something with req.user
50-
res.send(req.user ? 200 : 401);
51-
},
52-
);
53-
```
54-
55-
### Client Requests
56-
57-
Clients can send requests to routes that use passport-google-oauth-token authentication using `query parms`, `body`, or `HTTP headers`. Clients will need to transmit the `access_token`
58-
and optionally the `refresh_token` that are received from google after login.
59-
60-
## Options
61-
62-
| Field | Description | Default Value |
63-
| ------------------ | --------------------------------- | --------------------------------------------- |
64-
| clientID | Google's client id | |
65-
| clientSecret | Google's client secret | |
66-
| tokenURL | Google's oauth2 token url | https://www.googleapis.com/oauth2/v4/token |
67-
| profileURL | Google's scope profile url | https://www.googleapis.com/oauth2/v3/userinfo |
68-
| authorizationURL | Google's oauth2 authorization url | https://accounts.google.com/o/oauth2/v2/auth |
69-
| tokenURLVersion | Version of token url | v4 |
70-
| userinfoURLVersion | Version of profile url | v3 |
71-
| authURLVersion | Version of authorization url | v2 |
72-
73-
## Profile Example
74-
75-
```js
76-
{
77-
provider: 'google',
78-
id: '1234',
79-
displayName: 'Alpha',
80-
name: {
81-
familyName: 'Lucifer',
82-
givenName: 'Alpha',
83-
},
84-
emails: [
85-
{
86-
87-
verified: true,
88-
},
89-
],
90-
photos: [
91-
{
92-
value: 'https://google.com',
93-
},
94-
],
95-
_json: {},
96-
_raw: {},
97-
}
98-
```
99-
100-
## License
101-
102-
The MIT License (MIT)
103-
104-
Copyright (c) 2015 Nicholas Penree
105-
106-
Permission is hereby granted, free of charge, to any person obtaining a copy
107-
of this software and associated documentation files (the "Software"), to deal
108-
in the Software without restriction, including without limitation the rights
109-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
110-
copies of the Software, and to permit persons to whom the Software is
111-
furnished to do so, subject to the following conditions:
112-
113-
The above copyright notice and this permission notice shall be included in all
114-
copies or substantial portions of the Software.
115-
116-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
117-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
118-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
119-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
120-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
121-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
122-
SOFTWARE.
5+
- [passport-google-oauth-token](packages/passport-google-oauth-token/README.md)

0 commit comments

Comments
 (0)