-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Frontend][API][Update] Lexicon V2.0.0 (#53)
* sync latest version 2 changes (alpha) * Bug fix: Fix an error with the Topic and Post image URL when using a shortUrl as the source. * Bug fix: Post preview with a short URL uploads an image as the source. * add tool version, fixing nodejs to version 16 * fix quickstart command * fix react version due to expo request * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Ensure that Github Actions runs on alpha-v2 as well (#46) Co-authored-by: Kinostrome <[email protected]> * Improve Chinese Language Support & Fix Issue with Asset File Names (#47) * fix assets name * fix getting poster ditails for different language --------- Co-authored-by: jinqi.wei <[email protected]> * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (alpha) * Sync latest version 2 (beta) * Sync latest version 2 --------- Co-authored-by: Simon Biggs <[email protected]> Co-authored-by: Gabriella Putri <[email protected]> Co-authored-by: Kinostrome <[email protected]> Co-authored-by: Kinostrome <[email protected]> Co-authored-by: ShiChangshan <[email protected]> Co-authored-by: jinqi.wei <[email protected]>
- Loading branch information
1 parent
8913729
commit fdd8930
Showing
553 changed files
with
28,984 additions
and
12,652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
node_modules/**/* | ||
npm-debug.* | ||
|
||
.expo/* | ||
*/coverage | ||
*/.env | ||
*/playstore_secret.json | ||
|
||
frontend/web-build/ | ||
frontend/dist | ||
|
||
api/lib | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Ignoring other directories | ||
/documentation |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 16.20.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Internal Project Documentation | ||
|
||
## Usage of `git` | ||
|
||
As of Monday, July 3, 2023, usage of `rebase` and force pushing are no longer permitted on this project. | ||
|
||
`git merge` is the acceptable approach for resolving conflicts. | ||
|
||
### Example Scenario | ||
|
||
Typically what you'll do is `merge` the current branch with another branch (often `master`). | ||
|
||
For example, let's suppose you've been working on a feature branch named `feature/push-notifications`. | ||
|
||
Since you started making changes, `master` has received quite a few commits (from other PRs being merged in). | ||
|
||
In fact, you even need to incorporate some of those changes into your branch. | ||
|
||
_This approach is step-by-step and very explicit. There are shortcuts to accomplish this. In this case, we list out every step just to be clear._ | ||
|
||
#### Step 1: Checkout `master` and pull down the latest changes | ||
|
||
You need to ensure your local copy of `master` is up-to-date with what's on the remote. | ||
|
||
``` | ||
git checkout master && git pull | ||
``` | ||
|
||
#### Step 2: Switch back to your branch | ||
|
||
Now that `master` is up-to-date, switch back to `feature/push-notifications`. | ||
|
||
``` | ||
git checkout feature/push-notifications | ||
``` | ||
|
||
#### Step 3: Merge with `master` to synchronize your branch with it | ||
|
||
``` | ||
git merge master | ||
``` | ||
|
||
#### Step 4: Resolve any merge conflicts and commit the changes | ||
|
||
If there are no [conflicts](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts), the `merge` command will automatically reconcile the differences between the two branches with a specific merge strategy it selects. | ||
|
||
If there are changes that need to be resolved, it depends on your development environment. If you're using VS Code, it will automatically parse the files with [conflict markers](https://wincent.com/wiki/Understanding_Git_conflict_markers) and give you a basic UI on top of them to help decide which changes to keep. | ||
|
||
Note that sometimes, you may need to accept both changes and make further revisions manually to ensure that the final merged code is correct and hasn't broken anything / erased any changes. | ||
|
||
When making a manual merge, you will need to commit the changes you have made to perform the merge. Make sure this is done before attempting to push. | ||
|
||
#### Step 5: Push the updated branch | ||
|
||
Check `git log` (or a similar interface in your IDE) to view the most recent commit, and ensure it contains all of the latest merged changes. | ||
|
||
Once you have verified this, you can push your updated branch to the remote. It should now be synchronized with `master`. | ||
|
||
``` | ||
git push | ||
``` | ||
|
||
_Note, if you have not configured a default remote, this command may be something like `git push origin feature/push-notifications`._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules/**/* | |
coverage/ | ||
src/generated/ | ||
.env | ||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Basic Logger | ||
|
||
Last updated: 2023/08/28 | ||
|
||
## Motivation | ||
|
||
The Prose API needs a proper logging solution so that users of Lexicon who deploy it can monitor the service for issues. Based on our research, we decided to use Winston for our logger. Winston logger offers a versatile and efficient solution for logging. With support for multiple transport options, customizable log formatting, and different log levels, Winston provides developers with the flexibility to tailor their logging to specific needs. | ||
|
||
## Setup | ||
|
||
Winston is just a single dependency with the package name [winston](https://github.com/winstonjs/winston), so we added it to the project with `yarn add winston` from within the `api/` directory. | ||
|
||
## Transports | ||
|
||
In logging, a transport is a destination where logs are stored or displayed, such as a file, console, database, etc. In our logging setup, we mainly use the file transport. But during development, we also add the console transport. We chose the file transport because it offers a simple setup that logs directly into a file. We chose this over transports like [Http and Stream](https://github.com/winstonjs/winston/blob/master/docs/transports.md#built-in-to-winston) because server logs can sometimes contains sensitive information, so we don't want expose the logs on the open internet. | ||
|
||
We set up the file transport using a library called [winston-daily-rotate-file](https://github.com/winstonjs/winston-daily-rotate-file), which rotates the log file based on time. In addition to configuring the rotation frequency, we can also specify the maximum file size, the maximum number of files to retain, the number of days to keep files, and more. | ||
|
||
Referring to the guidance provided by the [OWASP Logging Cheatsheet](https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html), there are some important points to consider when storing logs in a file system: | ||
|
||
1. It is preferable to use a separate partition than those used by the operating system, other application files and user generated content. | ||
2. Apply strict permissions concerning which users can access the directories, and the permissions of files within the directories. | ||
3. In web applications, the logs should not be exposed in web-accessible locations, and if done so, should have restricted access and be configured with a plain text MIME type (not HTML). | ||
|
||
## Approach | ||
|
||
We make logging easier by directly connecting the logger to the `GraphQL Yoga` instance using a plugin called `useLogger`, which helps us keep all log calls in one central place. | ||
|
||
``` | ||
useLogger({ | ||
logFn: (eventName, events) => { | ||
// Event could be `execute-start` / `execute-end` / `subscribe-start` / `subscribe-end` | ||
// `args` will include the arguments passed to execute/subscribe (in case of "start" event) | ||
// and additional result in case of "end" event. | ||
switch (eventName) { | ||
case 'execute-end': | ||
case 'subscribe-end': | ||
// Do logging | ||
break; | ||
} | ||
}, | ||
}) | ||
``` | ||
|
||
We categorize our logs into two distinct files, one exclusively for 'error' level logs, and the other for a compilation of logs across all levels. | ||
|
||
## Future Improvement | ||
|
||
At the moment, our loggers are mainly used to catch any GraphQL errors that are thrown on the server side. But in the future, we're thinking about logging additional types of server errors, like runtime or network issues. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Typescript Usage | ||
|
||
The Prose GraphQL makes use of Typescript in multiple ways: | ||
|
||
- Nexus for schema generation, which generates Typescript types for use in the resolvers | ||
- Manual type definitions | ||
- As of Tuesday, August 15, 2023, we began incrementally adopting usage of [zod](https://github.com/colinhacks/zod) for type definitions and validation | ||
- @ts-reset for additional type safety checks | ||
|
||
Generally, this codebase strives to be as type-safe as possible, and we are always improving upon this. | ||
|
||
The original implementation was not very careful with types, and as such there are still cases of implicit any, type assertions, and other bad practices. | ||
|
||
Our adoption of tools like zod and @ts-reset are intended to help progressively address lingering type saftey issues. |
Oops, something went wrong.