How to use RedirectToWww method in argos

Best JavaScript code snippet using argos

Home.js

Source:Home.js Github

copy

Full Screen

1/* eslint-disable react/no-unescaped-entities */2import * as React from "react";3import { gql } from "graphql-tag";4import { x } from "@xstyled/styled-components";5import { Group } from "ariakit/group";6import { Query } from "../containers/Apollo";7import { useUser } from "../containers/User";8import { isUserSyncing } from "../modules/user";9import config from "../config";10import {11 BaseLink,12 Button,13 Card,14 CardBody,15 CardHeader,16 CardText,17 CardTitle,18 Container,19 Icon,20 Link,21 Loader,22 Menu,23 MenuButton,24 MenuIcon,25 MenuItem,26 MenuSeparator,27 MenuTitle,28 PrimaryTitle,29 Table,30 Tbody,31 Td,32 Th,33 Thead,34 Tr,35 useMenuState,36 IllustratedText,37 LinkBlock,38 Tag,39 TagButton,40} from "@argos-ci/app/src/components";41import {42 KebabHorizontalIcon,43 LinkExternalIcon,44 KeyIcon,45 GearIcon,46 LockIcon,47} from "@primer/octicons-react";48import { getStatusColor, StatusIcon } from "../containers/Status";49import { OwnerAvatar } from "../containers/OwnerAvatar";50import { hasWritePermission } from "../modules/permissions";51const HOME_OWNERS_REPOSITORIES_QUERY = gql`52 query HOME_OWNERS_REPOSITORIES_QUERY {53 owners {54 id55 name56 login57 type58 repositories {59 id60 name61 updatedAt62 enabled63 permissions64 builds(first: 1, after: 0) {65 pageInfo {66 totalCount67 }68 edges {69 id70 updatedAt71 status72 number73 }74 }75 }76 }77 }78`;79function RepositoryNameCell({80 owner,81 repositoryName,82 repositoryUrl,83 ...props84}) {85 return (86 <Td color="secondary-text" py={5} fontSize="lg" {...props}>87 <Link color="secondary-text" to={`/${owner.login}`}>88 <OwnerAvatar89 owner={owner}90 size="sm"91 display="inline-block"92 mr={2}93 mt={-0.5}94 />95 {owner.login}96 </Link>{" "}97 /{" "}98 <Link99 color="primary-text"100 fontWeight={600}101 to={`${repositoryUrl}/builds`}102 >103 {repositoryName}104 </Link>105 </Td>106 );107}108function ActionsMenuCell({ repository, repositoryUrl }) {109 const menu = useMenuState({ placement: "bottom-end", gutter: 4 });110 if (!hasWritePermission(repository))111 return (112 <Td>113 <Tag display="block" py={1} color="text-secondary">114 <Icon as={LockIcon} />115 </Tag>116 </Td>117 );118 return (119 <Td>120 <TagButton as={MenuButton} state={menu}>121 <Icon as={KebabHorizontalIcon} />122 </TagButton>123 <Menu aria-label="User settings" state={menu}>124 <MenuTitle>Repositories actions</MenuTitle>125 <MenuSeparator />126 <MenuItem127 state={menu}128 as={BaseLink}129 to={`${repositoryUrl}/settings#argos-token`}130 >131 <MenuIcon as={KeyIcon} />132 Get token133 </MenuItem>134 <MenuItem state={menu} as={BaseLink} to={`${repositoryUrl}/settings`}>135 <MenuIcon as={GearIcon} size={24} />136 Settings137 </MenuItem>138 </Menu>139 </Td>140 );141}142function BuildTagCell({ build, repositoryUrl, ...props }) {143 if (!build) return <Td>-</Td>;144 return (145 <Td>146 <TagButton147 as={LinkBlock}148 to={`${repositoryUrl}/builds/${build.number}`}149 borderColor={getStatusColor(status)}150 {...props}151 >152 <StatusIcon status={build.status} />#{build.number}153 </TagButton>154 </Td>155 );156}157function RepositoriesList({ repositories, ...props }) {158 if (repositories.length === 0) {159 return (160 <Card mt={3}>161 <CardHeader>162 <CardTitle>No repository found</CardTitle>163 </CardHeader>164 <CardBody>165 <CardText fontSize="md" mb={3}>166 Argos uses OAuth GitHub App.167 </CardText>168 <CardText fontSize="md">169 <Link href={config.get("github.appUrl")} target="_blank">170 Manage repositories' access restrictions from GitHub{" "}171 <LinkExternalIcon />172 </Link>173 </CardText>174 </CardBody>175 </Card>176 );177 }178 return (179 <Table {...props}>180 <Thead>181 <Tr>182 <Th>Repository name</Th>183 <Th width={120}>Last Build</Th>184 <Th width={120}>Status</Th>185 <Th width={80}>Actions</Th>186 </Tr>187 </Thead>188 <Tbody>189 {repositories.map(({ owner, ...repository }) => {190 const repositoryUrl = `/${owner.login}/${repository.name}`;191 const lastBuild = repository.builds?.edges?.[0];192 return (193 <Tr key={`${owner.login}-${repository.name}`}>194 <RepositoryNameCell195 owner={owner}196 repositoryName={repository.name}197 repositoryUrl={repositoryUrl}198 />199 <BuildTagCell build={lastBuild} repositoryUrl={repositoryUrl} />200 <Td>201 <Tag202 color={repository.enabled ? "primary-text" : "secondary-text"}203 >204 {repository.enabled ? "Active" : "Deactivated"}205 </Tag>206 </Td>207 <ActionsMenuCell208 repository={repository}209 repositoryUrl={repositoryUrl}210 />211 </Tr>212 );213 })}214 </Tbody>215 </Table>216 );217}218function Owners({ owners }) {219 const repositories = owners220 .flatMap((owner) =>221 owner.repositories.map((repository) => ({ owner, ...repository }))222 )223 .sort((a, b) => (b.enabled === a.enabled ? 0 : b.enabled ? 1 : -1));224 const activeRepositories = repositories.filter(({ enabled }) => enabled);225 const [activeFilter, setActiveFilter] = React.useState(226 activeRepositories.length !== 0227 );228 return (229 <Container>230 <PrimaryTitle>Organizations and Repositories</PrimaryTitle>231 <x.div232 display="flex"233 justifyContent="space-between"234 alignItems="flex-end"235 gap={10}236 >237 <x.div>238 Don't see your repo?{" "}239 <IllustratedText240 as={Link}241 reverse242 href={config.get("github.appUrl")}243 target="_blank"244 fontWeight="normal"245 icon={LinkExternalIcon}246 >247 Manage access restrictions248 </IllustratedText>{" "}249 or{" "}250 <Link onClick={() => window.location.reload()}>reload the page</Link>.251 </x.div>252 <x.div as={Group} display="flex">253 <Button254 borderRadius="md 0 0 md"255 variant="neutral"256 py={2}257 disabled={activeFilter}258 onClick={() => setActiveFilter(true)}259 >260 Active only261 </Button>262 <Button263 py={2}264 borderRadius="0 md md 0"265 variant="neutral"266 disabled={!activeFilter}267 onClick={() => setActiveFilter(false)}268 >269 Show all270 </Button>271 </x.div>272 </x.div>273 <RepositoriesList274 repositories={activeFilter ? activeRepositories : repositories}275 mt={3}276 />277 </Container>278 );279}280const RedirectToWww = () => {281 React.useEffect(() => {282 window.location = "https://www.argos-ci.com";283 }, []);284 return null;285};286export function Home() {287 const user = useUser();288 if (!user) {289 if (process.env.NODE_ENV !== "production") {290 return (291 <Container textAlign="center" my={4}>292 Not logged in, in production you would be redirected to293 www.argos-ci.com.294 </Container>295 );296 }297 return <RedirectToWww />;298 }299 if (!user.installations.length && !isUserSyncing(user)) {300 return (301 <Container textAlign="center" my={4}>302 <p>Look like you don't have installed Argos GitHub App.</p>303 <Button as="a" href={config.get("github.appUrl")}>304 Install Argos GitHub App305 </Button>306 </Container>307 );308 }309 return (310 <Query311 fallback={312 <Container my={3} textAlign="center">313 <Loader />314 </Container>315 }316 query={HOME_OWNERS_REPOSITORIES_QUERY}317 >318 {({ owners }) => <Owners owners={owners} />}319 </Query>320 );...

Full Screen

Full Screen

index.ts

Source:index.ts Github

copy

Full Screen

1// 入口文件处使用source-map2import sourceMap from 'source-map-support';3sourceMap.install();45// 模块路径解s析6require('module-alias/register');78import { baseUrl } from './config/index';9import express from 'express';10import path from 'path';1112import cookieParser from 'cookie-parser';1314import compression from 'compression';1516import redirectTowww from './middlewares/redirect-to-www'17import errorHandler from './middlewares/error-handle';18import router from './router';1920const app = express();2122// 全局捕获未处理的错误23process.on('uncaughtException', function(err) {24 process.exit(1);25});2627// 设置模板引擎28app.engine('html', require('ejs').__express);29app.set('view engine', 'html');30app.set('views', path.join(__dirname, 'www/views'));3132//设置静态资源目录33app.use('/static', express.static(path.join(__dirname, 'www/public')));3435// 解析cookie36app.use(cookieParser());3738// 压缩39app.use(compression());4041/* ----------- 只针对 /cgi-bin 的中间件 ----------- */42/**43 * 1. 超时中间件:超时错误的处理44 * 2. 回包格式化中间件:部署请求 resolve | reject 方法45 * 3. 数据上报中间件:统计 cgi 从开始接受请求到响应完成的耗时,对错误的信息进行上报46 **/47app.all(`/*`,redirectTowww);4849// 路由挂载50app.use(router);5152// 错误处理,需要在所有路由注册完毕之后才 use53// 处理 系统错误 | 服务器未知错误 | 请求逻辑错误54app.use(errorHandler);5556app.listen(80, () => console.log('Example app listening on port 80!')) ...

Full Screen

Full Screen

config.common.js

Source:config.common.js Github

copy

Full Screen

1/* eslint-disable filenames/match-exported */2const configForThisMode = {3 application: {4 name: 'Web Application Template'5 },6 server: {7 verbose: true,8 access: {9 publicDirectory: null,10 url: {11 http: {12 enabled: true,13 port: 80,14 redirectToHttps: true15 },16 https: {17 enabled: true,18 port: 44319 },20 redirectToWww: true21 }22 },23 logger: {24 showLogLine: {25 enabled: true,26 showRelativePath: true27 }28 }29 },30 webpack: {31 verbose: true,32 publicDirectory: null,33 useCopyWebpackPlugin: true,34 outputJsFilenamePattern: 'bundle.[name].[contenthash:20].js',35 outputCssFilenamePattern: 'bundle.[name].[contenthash:20].css'36 }37};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var http = require('http');3var port = 3000;4var server = http.createServer(function (req, res) {5 res.writeHead(200, { 'Content-Type': 'text/plain' });6 res.end('Hello World\n');7});8argosy.redirectToWww(server, port);9server.listen(port, function () {

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var argosyPattern = require('argosy-pattern');3var argosyInstance = argosy();4argosyInstance.use(argosyPattern({5 redirectToWww: argosyPattern.request({6 })7}));8argosyInstance.listen(8000);9 console.log(response);10});11var argosy = require('argosy');12var argosyPattern = require('argosy-pattern');13var argosyInstance = argosy();14argosyInstance.use(argosyPattern({15 redirectToWww: argosyPattern.request({16 })17}));18argosyInstance.listen(8000);19 console.log(response);20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2argosy.RedirectToWww('test.com', function(err, result) {3if (err) {4console.log(err);5}6else {7console.log(result);8}9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2argosy.redirectToWww('www.google.com', 80, 'google.com', 80);3var argosy = require('argosy');4argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'http');5var argosy = require('argosy');6argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'https');7var argosy = require('argosy');8argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'https', true);9var argosy = require('argosy');10argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'https', true, true);11var argosy = require('argosy');12argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'https', true, true, true);13var argosy = require('argosy');14argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'https', true, true, true, true);15var argosy = require('argosy');16argosy.redirectToWww('www.google.com', 80, 'google.com', 80, 'https', true, true, true, true, true);17var argosy = require('argosy');18argosy.redirectToWww('www.google.com', 80, 'google.com',

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var http = require('http');3var redirect = require('redirect-to-www');4var app = argosy();5app.use(argosy.pattern({role: 'redirect'}), redirect());6http.createServer(app).listen(80);

Full Screen

Using AI Code Generation

copy

Full Screen

1const argosy = require('argosy');2const argosyPatterns = require('argosy-patterns');3const argosyInstance = argosy();4 .use(argosyPatterns.patterns())5 .use(argosyPatterns.redirectToWww());6argosyInstance.listen({ port: 8080 });7### `argosyPatterns.redirectToWww(options)`8## `argosyPatterns.cors(options)`9## `argosyPatterns.corsPreflight(options)`

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var redirect = argosy.redirectToWww();3 if(err) {4 console.log('error: ', err);5 } else {6 console.log('result: ', result);7 }8});9var argosy = require('argosy');10var redirect = argosy.redirectToWww();11 if(err) {12 console.log('error: ', err);13 } else {14 console.log('result: ', result);15 }16});17#### redirectToWww(options)18* `options` - (Object) - Options object19var argosy = require('argosy');20var redirect = argosy.redirectToWww({ https: true });21 if(err) {22 console.log('error: ', err);23 } else {24 console.log('result: ', result);25 }26});27#### redirectToHttps(options)28* `options` - (Object) - Options object29var argosy = require('argosy');30var redirect = argosy.redirectToHttps();31 if(err) {32 console.log('error: ', err);33 } else {34 console.log('result: ', result);35 }36});37#### checkUrlExists(options

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var path = require('path');3var app = argosy({ path: path.resolve(__dirname, 'test.json') });4app.use(argosy.redirectToWww());5app.listen(3000);6var argosy = require('argosy');7var path = require('path');8var app = argosy({ path: path.resolve(__dirname, 'test.json') });9app.use(argosy.redirectFromWww());10app.listen(3000);11var argosy = require('argosy');12var path = require('path');13var app = argosy({ path: path.resolve(__dirname, 'test.json') });14app.use(argosy.redirectToHttps());15app.listen(3000);16var argosy = require('argosy');17var path = require('path');18var app = argosy({ path: path.resolve(__dirname, 'test.json') });19app.use(argosy.redirectFromHttps());20app.listen(3000);21var argosy = require('argosy');22var path = require('path');23var app = argosy({ path: path.resolve(__dirname, 'test.json') });24app.use(argosy.redirectToTrailingSlash());25app.listen(3000);26var argosy = require('argosy');27var path = require('path');28var app = argosy({ path: path

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful