Skip to content

Commit 759cca5

Browse files
committed
feat - move to codever.dev and add notes management
1 parent a41fa2c commit 759cca5

File tree

136 files changed

+18688
-1119
lines changed

Some content is hidden

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

136 files changed

+18688
-1119
lines changed

CHANGELOG.md

Lines changed: 74 additions & 74 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
<br />
1010

11-
:point_right: Use our [**HowTo pages**](https://www.codever.land/howto)
11+
:point_right: Use our [**HowTo pages**](https://www.codever.dev/howto)
1212
to get you going and [start saving time and nerves](https://dev.to/ama/how-i-manage-my-dev-bookmarks-and-save-time-and-nerves-56ae) when managing
1313
your bookmarks and code snippets. The following helpers and extensions will assist you along the way:
1414

1515
## Extensions
1616

17-
| [![Bookmarklet](documentation/img/bookmark-24.png)](https://www.codever.land/howto/bookmarklets) | [![Chrome](documentation/img/chrome-24.png)](https://chrome.google.com/webstore/detail/codever/diofdblfhjbpgackifolmboaiccmebjb) | [![Firefox](documentation/img/fx-24.png)](https://addons.mozilla.org/addon/codever/) | [![IntelliJ Plugin](documentation/img/intellij-24.png)](https://plugins.jetbrains.com/plugin/14456-codever-snippets/) | [![VSCode extension](documentation/img/vscode-24.png)](https://marketplace.visualstudio.com/items?itemName=codever.vscode-codever) |
17+
| [![Bookmarklet](documentation/img/bookmark-24.png)](https://www.codever.dev/howto/bookmarklets) | [![Chrome](documentation/img/chrome-24.png)](https://chrome.google.com/webstore/detail/codever/diofdblfhjbpgackifolmboaiccmebjb) | [![Firefox](documentation/img/fx-24.png)](https://addons.mozilla.org/addon/codever/) | [![IntelliJ Plugin](documentation/img/intellij-24.png)](https://plugins.jetbrains.com/plugin/14456-codever-snippets/) | [![VSCode extension](documentation/img/vscode-24.png)](https://marketplace.visualstudio.com/items?itemName=codever.vscode-codever) |
1818
|:---:|:---:|:---:|:---:|:---:|
19-
| [Bookmarklet](https://www.codever.land/howto/bookmarklets) | [Chromium Extension](https://chrome.google.com/webstore/detail/codever/diofdblfhjbpgackifolmboaiccmebjb) | [Firefox Addon](https://addons.mozilla.org/addon/codever/) | [IntelliJ Plugin](https://plugins.jetbrains.com/plugin/14456-codever-snippets/) | [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=codever.vscode-codever) |
19+
| [Bookmarklet](https://www.codever.dev/howto/bookmarklets) | [Chromium Extension](https://chrome.google.com/webstore/detail/codever/diofdblfhjbpgackifolmboaiccmebjb) | [Firefox Addon](https://addons.mozilla.org/addon/codever/) | [IntelliJ Plugin](https://plugins.jetbrains.com/plugin/14456-codever-snippets/) | [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=codever.vscode-codever) |
2020

2121
### Chrome extension usage example - save snippet
2222

@@ -28,7 +28,7 @@ your bookmarks and code snippets. The following helpers and extensions will assi
2828
## Public bookmarks
2929

3030
*******************************************************************************************************************************
31-
Worthy public bookmarks are published regularly on Github at [codeverland/bookmarks](https://github.com/codeverland/bookmarks).
31+
Worthy public bookmarks are published regularly on Github at [CodeverDotDev/bookmarks](https://github.com/CodeverDotDev/bookmarks).
3232
*******************************************************************************************************************************
3333

3434
## Setup (development or self hosting)
@@ -41,7 +41,7 @@ The project is developed with the MEAN stack and [Keycloak](http://www.keycloak.
4141
The project contains two parts
4242

4343
* [frontend](frontend) which makes up the User Interface. This uses with Angular and Angular CLI.
44-
* [backend](backend) which is the API supporting the UI. It uses ExpressJS with MongoDB and Keycloak. See the [OpenAPI specification](https://www.codever.land/api/docs)
44+
* [backend](backend) which is the API supporting the UI. It uses ExpressJS with MongoDB and Keycloak. See the [OpenAPI specification](https://www.codever.dev/api/docs)
4545

4646
### Prerequisites
4747

@@ -162,7 +162,7 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
162162

163163
## Versioning
164164

165-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/codeverland/codever/tags).
165+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/CodeverDotDev/codever/tags).
166166

167167
## Changelog
168168

backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The API has an OpenAPI specification available at [docs/openapi/openapi.yaml](do
2121

2222
Based on that a GUI is generated to test the API directly from browser:
2323
* [local](http://localhost:3000/api/docs)
24-
* [production](https://www.codever.land/api/docs)
24+
* [production](https://www.codever.dev/api/docs)
2525

2626
## Deployment
2727
We currently use [pm2](https://pm2.keymetrics.io/) to start the project in production

backend/docs/openapi/openapi.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
openapi: 3.0.3
22
info:
33
title: Codever API
4-
description: API supporting the [www.codever.land](https://www.codever.land)
4+
description: API supporting the [www.codever.land](https://www.codever.dev)
55
contact:
66
name: Adrian Matei
77
url: https://github.com/adrianmatei-me
88
email: ama@codepedia.org
99
license:
1010
name: License MIT
11-
url: https://github.com/codeverland/codever/LICENSE
11+
url: https://github.com/CodeverDotDev/codever/LICENSE
1212
version: 2.0.0
1313

1414
servers:
1515
- url: http://localhost:3000/api
1616
description: Local server for development
17-
- url: https://www.codever.land/api
17+
- url: https://www.codever.dev/api
1818
description: Main (production) server
1919

2020
tags:
@@ -191,7 +191,7 @@ paths:
191191
language: en
192192
tags: [nodejs, error-handling, expressjs]
193193
publishedOn: 2019-12-02,
194-
sourceCodeURL: https://github.com/codeverland/codever-api
194+
sourceCodeURL: https://github.com/CodeverDotDev/codever-api
195195
description: Shows how you can make your backend ExpressJS REST API cleaner by using custom error handling middleware. Code snippets of before and after refactoring are presented to make the point
196196
descriptionHtml: <p>Shows how you can make your backend ExpressJS REST API cleaner by using custom error handling middleware. Code snippets of before and after refactoring are presented to make the point</p>
197197
userId: 4c617f2b-2bad-498b-a9c6-4e9a8c303798

backend/docs/release-notes/2020-03-29-user-profile-release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Client - `keycloak-realm-admin-service-account`
1414
### Set display name for `user` via admin api call - DONE
1515
Get Access Token and Call admin api
1616
```
17-
PUT https://www.codever.land/api/admin/users/profile/display-name
17+
PUT https://www.codever.dev/api/admin/users/profile/display-name
1818
```
1919

2020
### Set displayName for bookmarks - DONE
@@ -24,7 +24,7 @@ PUT https://www.codever.land/api/admin/users/profile/display-name
2424

2525
Get Access Token and Call admin api
2626
```
27-
PUT https://www.codever.land/api/admin/users/profile/image-url
27+
PUT https://www.codever.dev/api/admin/users/profile/image-url
2828
```
2929

3030
### set AWS env variables in pm2 for prod - DONE

backend/env.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
"keycloak": {
4848
"realm": "bookmarks",
4949
"bearer-only": true,
50-
"auth-server-url": "https://www.codever.land/auth",
50+
"auth-server-url": "https://www.codever.dev/auth",
5151
"ssl-required": "external",
5252
"resource": "bookmarks-api"
5353
},
54-
"basicApiUrl": "https://www.codever.land/api"
54+
"basicApiUrl": "https://www.codever.dev/api"
5555
}
5656
}

backend/pm2-process.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"MONGODB_HOST": "localhost",
2323
"MONGODB_PORT": "27017",
2424
"KEYCLOAK_REALM": "bookmarks",
25-
"KEYCLOAK_SERVER_URL": "https://www.codever.land/auth"
25+
"KEYCLOAK_SERVER_URL": "https://www.codever.dev/auth"
2626
}
2727
}]
2828
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* ****** Bookmarks ****** */
2+
// delete old index
3+
db.notes.dropIndex("notes_full_text_search");
4+
5+
//recreate index
6+
db.notes.createIndex(
7+
{
8+
title: "text",
9+
reference: "text",
10+
content: "text",
11+
tags: "text"
12+
},
13+
{
14+
weights: {
15+
title: 13,
16+
reference: 3,
17+
content: 5,
18+
tags: 21
19+
},
20+
name: "notes_full_text_search",
21+
default_language: "none",
22+
language_override: "none"
23+
}
24+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
db.bookmarks.update(
2+
{},
3+
{ "$set": { "type": 'bookmark' } },
4+
{ "multi": true }
5+
);
6+
7+
db.snippets.update(
8+
{},
9+
{ "$set": { "type": 'snippet' } },
10+
{ "multi": true }
11+
);
12+
13+
db.notes.update(
14+
{},
15+
{ "$set": { "type": 'note' } },
16+
{ "multi": true }
17+
);
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
const Note = require('../model/note');
2+
3+
const bookmarksSearchHelper = require('./bookmarks-search.helper');
4+
5+
let findNotes = async function (userId, query, page, limit, searchInclude) {
6+
//split in text and tags
7+
const searchedTermsAndTags = bookmarksSearchHelper.splitSearchQuery(query);
8+
let searchedTerms = searchedTermsAndTags.terms;
9+
const searchedTags = searchedTermsAndTags.tags;
10+
let notes = [];
11+
12+
const {specialSearchFilters, nonSpecialSearchTerms} = bookmarksSearchHelper.extractSpecialSearchTerms(searchedTerms);
13+
14+
if ( searchedTerms.length > 0 && searchedTags.length > 0 ) {
15+
notes = await getNotesForTagsAndTerms(userId, searchedTags, nonSpecialSearchTerms, page, limit, specialSearchFilters, searchInclude);
16+
} else if ( searchedTerms.length > 0 ) {
17+
notes = await getNotesForSearchedTerms(userId, nonSpecialSearchTerms, page, limit, specialSearchFilters, searchInclude);
18+
} else {
19+
notes = await getNotesForSearchedTags(userId, searchedTags, page, limit, specialSearchFilters);
20+
}
21+
22+
return notes;
23+
}
24+
25+
let getNotesForTagsAndTerms = async function (userId, searchedTags, nonSpecialSearchTerms, page, limit, specialSearchFilters, searchInclude) {
26+
let filter = {
27+
tags:
28+
{
29+
$all: searchedTags
30+
}
31+
}
32+
33+
filter['userId'] = userId;
34+
35+
if ( nonSpecialSearchTerms.length > 0 ) {
36+
if ( searchInclude === 'any' ) {
37+
filter.$text = {$search: nonSpecialSearchTerms.join(' ')}
38+
} else {
39+
filter.$text = {$search: bookmarksSearchHelper.generateFullSearchText(nonSpecialSearchTerms)};
40+
}
41+
}
42+
43+
let notes = await Note.find(
44+
filter,
45+
{
46+
score: {$meta: "textScore"}
47+
}
48+
)
49+
.sort({score: {$meta: "textScore"}})
50+
.skip((page - 1) * limit)
51+
.limit(limit)
52+
.lean()
53+
.exec();
54+
55+
return notes;
56+
}
57+
58+
59+
let getNotesForSearchedTerms = async function (userId, nonSpecialSearchTerms, page, limit, specialSearchFilters, searchInclude) {
60+
61+
let filter = {};
62+
filter['userId'] = userId;
63+
64+
if ( nonSpecialSearchTerms.length > 0 ) {
65+
if ( searchInclude === 'any' ) {
66+
filter.$text = {$search: nonSpecialSearchTerms.join(' ')}
67+
} else {
68+
filter.$text = {$search: bookmarksSearchHelper.generateFullSearchText(nonSpecialSearchTerms)};
69+
}
70+
}
71+
72+
let notes = await Note.find(
73+
filter,
74+
{
75+
score: {$meta: "textScore"}
76+
}
77+
)
78+
.sort({score: {$meta: "textScore"}})
79+
.skip((page - 1) * limit)
80+
.limit(limit)
81+
.lean()
82+
.exec();
83+
84+
return notes;
85+
}
86+
87+
88+
let getNotesForSearchedTags = async function (userId, searchedTags, page, limit) {
89+
let filter = {
90+
tags:
91+
{
92+
$all: searchedTags
93+
}
94+
}
95+
filter['userId'] = userId;
96+
97+
98+
let notes = await Note.find(filter)
99+
.sort({createdAt: -1})
100+
.skip((page - 1) * limit)
101+
.limit(limit)
102+
.lean()
103+
.exec();
104+
105+
return notes;
106+
}
107+
108+
109+
module.exports = {
110+
findNotes: findNotes
111+
}

0 commit comments

Comments
 (0)