formatted
This commit is contained in:
parent
90c552a8f3
commit
06c8d9c66b
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
Tech stack:
|
Tech stack:
|
||||||
|
|
||||||
- pyjwt
|
- pyjwt
|
||||||
- redis
|
- redis
|
||||||
- ariadne
|
- ariadne
|
||||||
- starlette
|
- starlette
|
||||||
|
|
||||||
# Local development
|
# Local development
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
## Based on
|
## Based on
|
||||||
|
|
||||||
* pyjwt
|
- pyjwt
|
||||||
* [ariadne](https://github.com/mirumee/ariadne)
|
- [ariadne](https://github.com/mirumee/ariadne)
|
||||||
* [aioredis](https://github.com/aio-libs/aioredis)
|
- [aioredis](https://github.com/aio-libs/aioredis)
|
||||||
* [starlette](https://github.com/encode/starlette)、
|
- [starlette](https://github.com/encode/starlette)、
|
||||||
* sqlalchmy ORM
|
- sqlalchmy ORM
|
||||||
|
|
||||||
token is valid for one day, user can choose to logout, logout is revoke token
|
token is valid for one day, user can choose to logout, logout is revoke token
|
||||||
|
|
|
@ -10,8 +10,8 @@ pipenv install -r requirements.txt
|
||||||
|
|
||||||
## Using
|
## Using
|
||||||
|
|
||||||
Put the unpacked mongodump to the `data` folder and operate with `pipenv shell && python`
|
Put the unpacked mongodump to the `data` folder and operate with
|
||||||
|
`pipenv shell && python`
|
||||||
|
|
||||||
1. get old data jsons
|
1. get old data jsons
|
||||||
|
|
||||||
|
@ -23,19 +23,16 @@ bson2json.json_tables() # creates all the needed data json from bson mongodump
|
||||||
|
|
||||||
2. migrate users
|
2. migrate users
|
||||||
|
|
||||||
```py
|
```sh
|
||||||
import json
|
pipenv run python migrate.py users
|
||||||
from migrations.users import migrate
|
|
||||||
|
|
||||||
data = json.loads(open('data/users.json').read())
|
|
||||||
newdata = {}
|
|
||||||
|
|
||||||
for u in data:
|
|
||||||
try:
|
|
||||||
newdata[u['_id']] = migrate(u)
|
|
||||||
except:
|
|
||||||
print('FAIL!')
|
|
||||||
print(u)
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Note: this will create db entries and it is not tolerant to existed unique email.
|
||||||
|
|
||||||
|
3. then topics and shouts
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pipenv run python migrate.py topics
|
||||||
|
pipenv run python migrate.py shouts
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you got the *.dict.json files which contain all the data with old and new(!) ids.
|
|
@ -3,36 +3,36 @@ scalar DateTime
|
||||||
################################### Payload
|
################################### Payload
|
||||||
|
|
||||||
type Result {
|
type Result {
|
||||||
error: String
|
error: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthResult {
|
type AuthResult {
|
||||||
error: String
|
error: String
|
||||||
token: String
|
token: String
|
||||||
user: User
|
user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserResult {
|
type UserResult {
|
||||||
error: String
|
error: String
|
||||||
user: User
|
user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageResult {
|
type MessageResult {
|
||||||
error: String
|
error: String
|
||||||
message: Message
|
message: Message
|
||||||
}
|
}
|
||||||
|
|
||||||
input ShoutInput {
|
input ShoutInput {
|
||||||
org_id: Int!
|
org_id: Int!
|
||||||
slug: String!
|
slug: String!
|
||||||
body: String!
|
body: String!
|
||||||
replyTo: String # another shout
|
replyTo: String # another shout
|
||||||
tags: [String] # actual values
|
tags: [String] # actual values
|
||||||
topics: [String] # topic-slugs
|
topics: [String] # topic-slugs
|
||||||
title: String
|
title: String
|
||||||
versionOf: String
|
versionOf: String
|
||||||
visibleForRoles: [String] # role ids are strings
|
visibleForRoles: [String] # role ids are strings
|
||||||
visibleForUsers: [Int]
|
visibleForUsers: [Int]
|
||||||
}
|
}
|
||||||
|
|
||||||
input ProfileInput {
|
input ProfileInput {
|
||||||
|
@ -42,33 +42,33 @@ input ProfileInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShoutResult {
|
type ShoutResult {
|
||||||
error: String
|
error: String
|
||||||
shout: Shout
|
shout: Shout
|
||||||
}
|
}
|
||||||
|
|
||||||
################################### Mutation
|
################################### Mutation
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
# message
|
# message
|
||||||
createMessage(body: String!, replyTo: Int): MessageResult!
|
createMessage(body: String!, replyTo: Int): MessageResult!
|
||||||
updateMessage(id: Int!, body: String!): MessageResult!
|
updateMessage(id: Int!, body: String!): MessageResult!
|
||||||
deleteMessage(messageId: Int!): Result!
|
deleteMessage(messageId: Int!): Result!
|
||||||
|
|
||||||
# auth
|
# auth
|
||||||
confirmEmail(token: String!): AuthResult!
|
confirmEmail(token: String!): AuthResult!
|
||||||
requestPasswordReset(email: String!): Boolean!
|
requestPasswordReset(email: String!): Boolean!
|
||||||
confirmPasswordReset(token: String!): Boolean!
|
confirmPasswordReset(token: String!): Boolean!
|
||||||
registerUser(email: String!, password: String!): AuthResult!
|
registerUser(email: String!, password: String!): AuthResult!
|
||||||
# updatePassword(password: String!, token: String!): Token!
|
# updatePassword(password: String!, token: String!): Token!
|
||||||
# invalidateAllTokens: Boolean!
|
# invalidateAllTokens: Boolean!
|
||||||
# invalidateTokenById(id: Int!): Boolean!
|
# invalidateTokenById(id: Int!): Boolean!
|
||||||
# requestEmailConfirmation: User!
|
# requestEmailConfirmation: User!
|
||||||
|
|
||||||
# shout
|
# shout
|
||||||
createShout(input: ShoutInput!): ShoutResult!
|
createShout(input: ShoutInput!): ShoutResult!
|
||||||
updateShout(input: ShoutInput!): ShoutResult!
|
updateShout(input: ShoutInput!): ShoutResult!
|
||||||
deleteShout(slug: String!): Result!
|
deleteShout(slug: String!): Result!
|
||||||
rateShout(slug: String!, value: Int!): Result!
|
rateShout(slug: String!, value: Int!): Result!
|
||||||
|
|
||||||
# user profile
|
# user profile
|
||||||
# rateUser(value: Int!): Result!
|
# rateUser(value: Int!): Result!
|
||||||
|
@ -80,11 +80,11 @@ type Mutation {
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
# auth
|
# auth
|
||||||
isEmailFree(email: String!): Result!
|
isEmailFree(email: String!): Result!
|
||||||
signIn(email: String!, password: String!): AuthResult!
|
signIn(email: String!, password: String!): AuthResult!
|
||||||
signOut: Result!
|
signOut: Result!
|
||||||
# user profile
|
# user profile
|
||||||
getCurrentUser: UserResult!
|
getCurrentUser: UserResult!
|
||||||
getUserById(id: Int!): UserResult!
|
getUserById(id: Int!): UserResult!
|
||||||
# getUserRating(shout: Int): Int!
|
# getUserRating(shout: Int): Int!
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ type Query {
|
||||||
# shoutsByTime(time: DateTime): [Shout]!
|
# shoutsByTime(time: DateTime): [Shout]!
|
||||||
|
|
||||||
# getOnlineUsers: [User!]!
|
# getOnlineUsers: [User!]!
|
||||||
topAuthors: [User]!
|
topAuthors: [User]!
|
||||||
topShouts: [Shout]!
|
topShouts: [Shout]!
|
||||||
}
|
}
|
||||||
|
|
||||||
############################################ Subscription
|
############################################ Subscription
|
||||||
|
@ -215,7 +215,6 @@ type Topic {
|
||||||
|
|
||||||
# TODO: resolvers to add/remove topics from publication
|
# TODO: resolvers to add/remove topics from publication
|
||||||
|
|
||||||
|
|
||||||
type Proposal {
|
type Proposal {
|
||||||
body: String!
|
body: String!
|
||||||
shout: Int!
|
shout: Int!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user