File tree Expand file tree Collapse file tree 6 files changed +76
-39
lines changed Expand file tree Collapse file tree 6 files changed +76
-39
lines changed Original file line number Diff line number Diff line change
1
+
2
+ export default async function handler ( request , response ) {
3
+
4
+ const https = require ( 'https' ) ;
5
+
6
+ console . log ( request ) ;
7
+
8
+ const { status, data} = await getRequest ( decodeURIComponent ( request . query . url ) ) ;
9
+
10
+ response . status ( status ) . send ( data ) ;
11
+
12
+
13
+ function getRequest ( url ) {
14
+
15
+ return new Promise ( resolve => {
16
+
17
+ const req = https . get ( url , ( resp ) => {
18
+
19
+ let data = '' ;
20
+
21
+ resp . on ( 'data' , ( chunk ) => {
22
+
23
+ data += chunk ;
24
+
25
+ } ) ;
26
+
27
+ resp . on ( 'end' , ( ) => {
28
+
29
+ resolve ( { status : resp . statusCode , data : data } ) ;
30
+
31
+ } ) ;
32
+
33
+ } ) ;
34
+
35
+ } ) ;
36
+
37
+ }
38
+
39
+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ export default function handler(request, response) {
3
3
4
4
const query = request . query ;
5
5
6
- let html = ' Try adding a <code>?url=</code>.' ;
6
+ let json = { "error" : " Try adding a URL" } ;
7
7
8
8
if ( query . url ) {
9
9
@@ -13,17 +13,23 @@ export default function handler(request, response) {
13
13
url = 'https://dev.codeit.codes' ;
14
14
}
15
15
16
- html = `
17
- <oembed>
18
- <html><iframe src="` + url + `/api/link?url=` + query . url + `&embed=true" width="700" height="480" style="border-radius: 10px;" allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write" allowfullscreen="true" allowpaymentrequest="true" loading="lazy" sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" scrolling="yes" frameborder="0"></iframe></html>
19
- <width>700</width>
20
- <height>480</height>
21
- </oembed>
22
- ` ;
16
+ const embedHTML = `<iframe src="` + url + `/api/link?url=` + query . url + `&embed=true" width="700" height="480" style="border-radius: 10px;" allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write" allowfullscreen="true" allowpaymentrequest="true" loading="lazy" sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" scrolling="yes" frameborder="0"></iframe></html>` ;
17
+
18
+ json = {
19
+ "type" : "rich" ,
20
+ "title" : "Codeit" ,
21
+ "width" : 700 ,
22
+ "height" : 480 ,
23
+ "html" : embedHTML ,
24
+ "version" : "1.0" ,
25
+ "cache_age" : 3600 ,
26
+ "provider_name" : "Codeit" ,
27
+ "provider_url" : "https://codeit.codes/"
28
+ } ;
23
29
24
30
}
25
31
26
- response . status ( 200 ) . send ( html ) ;
32
+ response . status ( 200 ) . json ( json ) ;
27
33
28
34
}
29
35
Original file line number Diff line number Diff line change @@ -1504,6 +1504,9 @@ body:not(.mobile) .sidebar .header .title .branch-icon:active {
1504
1504
height : 50px ;
1505
1505
width : 233px ;
1506
1506
font-weight : 500 ;
1507
+ }
1508
+
1509
+ body .mobile .sidebar .button {
1507
1510
transition : .1s var (--ease-function );
1508
1511
transition-property : background, color;
1509
1512
}
Original file line number Diff line number Diff line change @@ -143,10 +143,10 @@ async function getGithubToken(gitCode) {
143
143
144
144
// post through CORS proxy to git with clientId, clientSecret and code
145
145
const resp = await axios . post ( 'https://scepter-cors2.herokuapp.com/' +
146
- 'https://github.com/login/oauth/access_token?' +
147
- 'client_id=7ede3eed3185e59c042d' +
148
- '&client_secret=c1934d5aab1c957800ea8e84ce6a24dda6d68f45' +
149
- '&code=' + gitCode ) ;
146
+ 'https://github.com/login/oauth/access_token?' +
147
+ 'client_id=7ede3eed3185e59c042d' +
148
+ '&client_secret=c1934d5aab1c957800ea8e84ce6a24dda6d68f45' +
149
+ '&code=' + gitCode ) ;
150
150
151
151
// save git token to localStorage
152
152
gitToken = resp . access_token ;
Original file line number Diff line number Diff line change @@ -78,35 +78,30 @@ window.onload = async () => {
78
78
79
79
window . addEventListener ( 'message' , ( event ) => {
80
80
81
- // if redirected from git auth
82
- if ( event . source . location . pathname === '/git/gitlab/oauth' ) {
83
-
84
- // hide intro screen
85
- sidebar . classList . remove ( 'intro' ) ;
81
+ // hide intro screen
82
+ sidebar . classList . remove ( 'intro' ) ;
86
83
87
- // if on safari, refresh header color
88
- if ( isSafari ) {
84
+ // if on safari, refresh header color
85
+ if ( isSafari ) {
89
86
90
- document . querySelector ( 'meta[name="theme-color"]' ) . content = '#313744' ;
87
+ document . querySelector ( 'meta[name="theme-color"]' ) . content = '#313744' ;
91
88
92
- onNextFrame ( ( ) => {
89
+ onNextFrame ( ( ) => {
93
90
94
- document . querySelector ( 'meta[name="theme-color"]' ) . content = '#1a1c24' ;
91
+ document . querySelector ( 'meta[name="theme-color"]' ) . content = '#1a1c24' ;
95
92
96
- } ) ;
93
+ } ) ;
97
94
98
- }
95
+ }
99
96
100
- // start loading
101
- startLoading ( ) ;
97
+ // start loading
98
+ startLoading ( ) ;
102
99
103
- const gitCode = event . data ;
100
+ const gitCode = event . data ;
104
101
105
- // get git token from Gitlab
106
- getGitlabToken ( gitCode ) ;
102
+ // get git token from Gitlab
103
+ getGitlabToken ( gitCode ) ;
107
104
108
- }
109
-
110
105
} )
111
106
112
107
@@ -171,9 +166,3 @@ async function getGitlabToken(gitCode) {
171
166
172
167
}
173
168
174
-
175
-
176
-
177
-
178
- await axios . post ( 'https://gitlab.com/oauth/token?client_id=&client_secret=&code=&&redirect_uri=https://codeit.codes/git/gitlab/oauth' )
179
-
Original file line number Diff line number Diff line change 4
4
5
5
6
6
// update worker name when updating worker
7
- const WORKER_NAME = 'codeit-worker-v527 ' ;
7
+ const WORKER_NAME = 'codeit-worker-v531 ' ;
8
8
9
9
10
10
// internal paths
You can’t perform that action at this time.
0 commit comments