Skip to content

Commit 97cc837

Browse files
committed
Initial version
1 parent 868849c commit 97cc837

File tree

123 files changed

+27249
-1
lines changed

Some content is hidden

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

123 files changed

+27249
-1
lines changed

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
### Angular ###
2+
## Angular ##
3+
# compiled output
4+
/dist
5+
/tmp
6+
/app/**/*.js
7+
/app/**/*.js.map
8+
9+
# dependencies
10+
/node_modules
11+
/bower_components
12+
13+
# IDEs and editors
14+
/.idea
15+
16+
# misc
17+
/.sass-cache
18+
/connect.lock
19+
/coverage/*
20+
/libpeerconnection.log
21+
npm-debug.log
22+
testem.log
23+
/typings
24+
25+
# e2e
26+
/e2e/*.js
27+
/e2e/*.map
28+
29+
#System Files
30+
.DS_Store
31+
32+
### VisualStudioCode ###
33+
.vscode/*
34+
!.vscode/settings.json
35+
!.vscode/tasks.json
36+
!.vscode/launch.json
37+
!.vscode/extensions.json
38+
39+
### VisualStudioCode Patch ###
40+
# Ignore all local history of files
41+
.history
42+
package-lock.json
43+
*.xml

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 xiayinchang
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README-en.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# coderiver-angular
2+
3+
A fullstack JavaScript project, using technologies from the modern stack, such as:
4+
5+
- [NestJS](https://github.com/nestjs/nest) - a JS backend framework providing architecture out of the box with a syntax similar to Angular
6+
- [Angular](https://github.com/angular/angular) - a JS frontend framework created by Google
7+
- [Angular Universal](https://github.com/angular/universal) - Angular Server Side Rendering - prerendered crawlable pages
8+
- [RxJS](https://github.com/Reactive-Extensions/RxJS) - reactive extensions for JavaScript
9+
- [Webpack](https://github.com/webpack/webpack) - the ultimate JS bundler - used for the server code since Angular has it under the hood
10+
- [MongoDB](https://github.com/mongodb/mongo) - a NoSQL database
11+
- [Mongoose](https://github.com/Automattic/mongoose) - MongoDB object modeling designed to work in an asynchronous environment
12+
- [TypeScript](https://github.com/Microsoft/TypeScript) - superset of JS which compiles to JS, providing compile-time type checking
13+
- [Passport](https://github.com/jaredhanson/passport) - a popular library used to implement JavaScript authentication
14+
- [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) - a JavaScript json web tokens implementation by auth0
15+
16+
## Running the project
17+
18+
These instructions should be sufficient for one to get the project going on their local machine
19+
20+
### Cloning the github repository
21+
22+
To clone the project, run
23+
24+
```
25+
git clone https://github.com/bojidaryovchev/coderiver-angular.git
26+
```
27+
28+
### Installing the dependencies
29+
30+
To install the dependencies after you've cloned the project, go to its root folder and run
31+
32+
```
33+
npm install
34+
```
35+
36+
### Building the Angular application
37+
38+
Before you start the server, you need to build the Angular application. To do so, run
39+
40+
```
41+
npm run build:universal
42+
```
43+
44+
### Starting the server
45+
46+
Once you have the Angular app built, you can start the server by running
47+
48+
```
49+
npm run watch:server
50+
```
51+
52+
Notice that the server uses MongoDB so we need to have a MongoDB instance running so the server can connect to it
53+
54+
### Alternative commands
55+
56+
If you need to work on the frontend and backend parts at the same time, you can run
57+
58+
```
59+
npm run watch
60+
```
61+
62+
Then, you can go to the Angular dev server at port 4200 and test server requests (to port 1337), we got a proxy to the backend
63+
64+
If you only need to work on the frontend, you can run
65+
66+
```
67+
npm run watch:client
68+
```
69+
70+
Alternatively, if you only need to work on the backend, you can run
71+
72+
```
73+
npm run watch:server
74+
```
75+
76+
Keeping in mind that you need to have the Angular app built and a mongodb connection established
77+
78+
## Instructions
79+
80+
### Getting GraphQL to work
81+
82+
Currently there are issues with several packages so even though we have GraphQL implemented, it stays commented out because it doesn't work.. Here are the instructions to make it work:
83+
84+
- Download https://www.dropbox.com/s/7bvht9thbmwt1e5/fixed-apollo-modules.rar?dl=0 - those are the apollo-angular and apollo-angular-link-http modules compiled in commonjs - then go in your node_modules folder and replace your apollo-angular and apollo-angular-link-http modules with these ones
85+
- Download https://www.dropbox.com/s/n0vwfvdmn7wtkj8/fixed-nest-modules.rar?dl=0 - this is the fixed @nestjs/graphql module - there was an error when in combination with Angular Universal which is now fixed - then replace your @nestjs/graphql module with this one
86+
- Open node_modules/@types/ws/index.d.ts and find net.AddressInfo - you will see a type definition of a function:
87+
`address(): net.AddressInfo | string` - change it to `address(): string`
88+
89+
Now, you can go ahead and uncomment the GraphqlModules on both client/server side and it works decently, I am using it in another project which is a clone of this one and everything works..
90+
91+
### Use Social login
92+
93+
Modify with your application credentials:
94+
95+
- src/server/modules/auth/config/facebook-config.ts
96+
- src/server/modules/auth/config/google-config.ts
97+
- src/server/modules/auth/config/twitter-config.ts
98+
99+
To use it in mobile application with Facebook-token integration (Facebook App), use /api/auth/facebook/token endpoint.

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
# coderiver-angular
1+
<p align="center">
2+
<a href="http://www.coderiver.cn">
3+
<img width="100" src="https://avatars2.githubusercontent.com/u/46118421?s=400&u=428a96d53bb16788f49da9f39c08187755222644&v=4">
4+
</a>
5+
</p>
6+
7+
<h1 align="center">
8+
CodeRiver
9+
</h1>
10+
11+
<div align="center">
12+
13+
一个。
14+
15+
<!-- [![Build Status](https://travis-ci.org/ng-alain/ng-alain.svg?branch=master)](https://travis-ci.org/ng-alain/ng-alain)
16+
[![Dependency Status](https://david-dm.org/ng-alain/ng-alain/status.svg)](https://david-dm.org/ng-alain/ng-alain)
17+
[![GitHub Release Date](https://img.shields.io/github/release-date/ng-alain/ng-alain.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/releases)
18+
[![NPM version](https://img.shields.io/npm/v/ng-alain.svg)](https://www.npmjs.com/package/ng-alain)
19+
[![NPM version](https://img.shields.io/npm/v/ng-alain/next.svg)](https://www.npmjs.com/package/ng-alain)
20+
[![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://prettier.io/)
21+
[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/blob/master/LICENSE)
22+
[![Gitter](https://img.shields.io/gitter/room/ng-alain/ng-alain.svg?style=flat-square)](https://gitter.im/ng-alain/ng-alain)
23+
[![extension-for-VSCode](https://img.shields.io/badge/extension%20for-VSCode-blue.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=cipchk.ng-alain-vscode)
24+
[![Backers on Open Collective](https://opencollective.com/ng-alain/backers/badge.svg)](#backers)
25+
[![Sponsors on Open Collective](https://opencollective.com/ng-alain/sponsors/badge.svg)](#sponsors) -->
26+
27+
</div>
28+
29+
[English](README-en.md) | 简体中文
30+
31+
## 快速开始
32+
33+
```bash
34+
npm install -g @angular/cli
35+
npm i
36+
ng serve
37+
```
38+
39+
40+
### License
41+
42+
The MIT License (see the [LICENSE](https://github.com/coderiver-org/coderiver-angular/blob/master/LICENSE) file for the full text)

_mock/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[Document](https://ng-alain.com/mock)

_mock/_user.ts

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { MockRequest } from '@delon/mock';
2+
3+
const list: any[] = [];
4+
const total = 50;
5+
6+
for (let i = 0; i < total; i += 1) {
7+
list.push({
8+
id: i + 1,
9+
disabled: i % 6 === 0,
10+
href: 'https://ant.design',
11+
avatar: [
12+
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
13+
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
14+
][i % 2],
15+
no: `TradeCode ${i}`,
16+
title: `一个任务名称 ${i}`,
17+
owner: '曲丽丽',
18+
description: '这是一段描述',
19+
callNo: Math.floor(Math.random() * 1000),
20+
status: Math.floor(Math.random() * 10) % 4,
21+
updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
22+
createdAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
23+
progress: Math.ceil(Math.random() * 100),
24+
});
25+
}
26+
27+
function genData(params: any) {
28+
let ret = [...list];
29+
const pi = +params.pi,
30+
ps = +params.ps,
31+
start = (pi - 1) * ps;
32+
33+
if (params.no) {
34+
ret = ret.filter(data => data.no.indexOf(params.no) > -1);
35+
}
36+
37+
return { total: ret.length, list: ret.slice(start, ps * pi) };
38+
}
39+
40+
function saveData(id: number, value: any) {
41+
const item = list.find(w => w.id === id);
42+
if (!item) { return { msg: '无效用户信息' }; }
43+
Object.assign(item, value);
44+
return { msg: 'ok' };
45+
}
46+
47+
export const USERS = {
48+
'/user': (req: MockRequest) => genData(req.queryString),
49+
'/user/:id': (req: MockRequest) => list.find(w => w.id === +req.params.id),
50+
'POST /user/:id': (req: MockRequest) => saveData(+req.params.id, req.body),
51+
'/user/current': {
52+
name: 'Cipchk',
53+
avatar:
54+
'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
55+
userid: '00000001',
56+
email: 'cipchk@qq.com',
57+
signature: '海纳百川,有容乃大',
58+
title: '交互专家',
59+
group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
60+
tags: [
61+
{
62+
key: '0',
63+
label: '很有想法的',
64+
},
65+
{
66+
key: '1',
67+
label: '专注撩妹',
68+
},
69+
{
70+
key: '2',
71+
label: '帅~',
72+
},
73+
{
74+
key: '3',
75+
label: '通吃',
76+
},
77+
{
78+
key: '4',
79+
label: '专职后端',
80+
},
81+
{
82+
key: '5',
83+
label: '海纳百川',
84+
},
85+
],
86+
notifyCount: 12,
87+
country: 'China',
88+
geographic: {
89+
province: {
90+
label: '上海',
91+
key: '330000',
92+
},
93+
city: {
94+
label: '市辖区',
95+
key: '330100',
96+
},
97+
},
98+
address: 'XX区XXX路 XX 号',
99+
phone: '你猜-你猜你猜猜猜',
100+
},
101+
'POST /user/avatar': 'ok',
102+
'POST /login/account': (req: MockRequest) => {
103+
const data = req.body;
104+
if (
105+
!(data.userName === 'admin' || data.userName === 'user') ||
106+
data.password !== 'ng-alain.com'
107+
) {
108+
return { msg: `Invalid username or password(admin/ng-alain.com)` };
109+
}
110+
return {
111+
msg: 'ok',
112+
user: {
113+
token: '123456789',
114+
name: data.userName,
115+
email: `${data.userName}@qq.com`,
116+
id: 10000,
117+
time: +new Date(),
118+
},
119+
};
120+
},
121+
'POST /register': {
122+
msg: 'ok',
123+
},
124+
};

_mock/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './_user';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy